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

Write a house class that has the following properties: Number of bedrooms. Boole

ID: 3532388 • Letter: W

Question

Write a house class that has the following properties:

Number of bedrooms.

Boolean to indicate if there is a formal dining room

House size in square feet (calculated by adding the sizes of all the rooms)

Total number of rooms ( calculated: number of bedrooms + formal dining room if present + 1 for kitchen)Number of baths (house can have any number of 1/2 bath or 1/4 of a bath in addition to a full bath - example 1.5, 1.75 or 1.25 bath)

Write the following method

Contructors (2 constructors, default constructor and constructor that you pass bedrooms and bathrooms to)

set methods for number of bedrooms and number of baths

get methods for all fields

The house must calculate its own size by adding all room sizes. Assume each bedroom is 144sf, Kitchen is 100sf, dinning is 150sf, bathroom is 40sf.

The house must calculate its own number of rooms..

Explanation / Answer

public class house{

int numberOfBedrooms;

static boolean formalDiningRoom;

double totalNumberOfRooms;

double numberOfBaths;

double size;

house(){

this.size=this.numberOfBedrooms*144+1*150+1*100+this.numberOfBaths*40;

}

house(int bedrooms,double baths){

this.numberOfBedrooms=bedrooms;

this.numberOfBaths=baths;

if(formalDiningRoom){

this.totalNumberOfRooms=bedrooms+1+1+baths;

this.size=bedrooms*144+1*150+1*100+baths*40;

}

else{

this.totalNumberOfRooms=bedrooms+1+numberOfBaths;

}

}

public void setBedrooms(int a){

this.numberOfBedrooms=a;

}

public void setBaths(double b){

this.numberOfBaths=b;

}

public double getBaths(){

return this.numberOfBaths;

}

public int getBedrooms(){

return this.numberOfBedrooms;

}

public void getbedroom(){

if(formalDiningRoom) System.out.println("formal dining room is present");

else System.out.println("No formal dining room is present");

}

public double sizeOfHouse(){

return this.size;

}

}

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