Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need this program to be coded using Java Deline a class (call it Soom) that ha

ID: 3724869 • Letter: I

Question

I need this program to be coded using Java

Deline a class (call it Soom) that has two instance varables of foat tupe representing the length and width of a room The class shouit have a sublic sunic variable of fioat type representing the number of rooms The class shouits haue the following methods a. Defbult constructor that will initalize instance variabies to d b. Constractor that will initialize the instance variables to the parameee values c. The constructor should increment the static variable w/hem an object of the class is defined or instantilated d. Accessors: getlength, getwith e. Mutators settength, setwidth, set the length and width using the parameter value f area() that will compute and return the area g. perimeter) that will compute and returh the perimeter h. toString0 that will return a string ideating length, wde·area and perimeter Write a Java application to test the Room class above. Define several Room objects and make calls to the different methods Write another class name it House. A House object should have 5 Room objects (bedRoom1, bedroom2, livingRoom, kitchen and diningRoom) as instance variables. The class should include the foillowing methods j totalSqrt) that will compute and return the total square feet for the k. toString) that will return a string representing the House object- L setRoom) that will set the information for a Room object using a house rooms, room areas and total square feet Room object as a parameter with specified type for the room. The Room object will be updated based on the room type (bedRooml bedRoom2, livingRoom, kitchen and diningRoom

Explanation / Answer

Room.java

.

public class Room {

float length;

float width;

float area_room;

float peri_room;

public static float numberofrooms;

Room(){

length=0;

width=0;

numberofrooms++;

}

public Room(float length, float width) {

super();

this.length = length;

this.width = width;

}

public float getLength() {

return length;

}

public void setLength(float length) {

this.length = length;

}

public float getWidth() {

return width;

}

public void setWidth(float width) {

this.width = width;

}

public float area() {

area_room = width*length;

return area_room;

}

public float perimeter() {

peri_room = 2*(width+length);

return peri_room;

}

public String toString() {

return length+" "+width+" "+area_room+" "+peri_room;

}

}

RoomMain.java

.

package com.Chegg;

public class RoomMain {

public static void main(String[] args) {

Room r1 = new Room();

Room r2 = new Room(12, 15);

System.out.println(r1.toString());

System.out.println(r2.toString());

Room r3 = new Room();

System.out.println(r1.numberofrooms);

System.out.println(r2.getLength());

}

}

House.java

.

package com.Chegg;

public class House {

Room bedroom1;

Room bedroom2;

Room livingroom;

Room kitchen;

Room diningroom;

float totalarea;

House(){

bedroom1= new Room();

bedroom2= new Room();

livingroom = new Room();

kitchen= new Room();

diningroom = new Room();

}

public float totalsqrt() {

totalarea = bedroom1.area()+bedroom2.area()+livingroom.area()+kitchen.area()+diningroom.area();

return totalarea;

}

public String toString() {

return bedroom1.length+" "+bedroom1.area()+bedroom2.length+" "+bedroom2.area()+livingroom.length+" "+livingroom.area()+" "+

kitchen.length+" "+kitchen.area()+diningroom.length+" "+diningroom.area()+" "+totalarea;

}

public static void main(String[] args) {

House h1 = new House();

h1.totalsqrt();

System.out.println(h1.toString());

System.out.println(h1.totalsqrt());

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote