Question: Hi there! Need help creating this Java program. : ) Your task is to create a Java class called House and a corresponding driver program
Hi there! Need help creating this Java program. :
Your task is to create a Java class called House and a corresponding driver program to interact with it
Class Attributes:
The House class should contain the following instance variables:
address String: The address of the house.
numBedrooms int: The number of bedrooms in the house.
numBathrooms double: The number of bathrooms in the house a bathroom can be a halfbathroom, hence the double data type
price double: The current market price of the house.
squareFeet int: The total area of the house in square feet.
Constructors:
You should define two constructors for the House class:
Default Constructor: This constructor does not take any arguments and initializes address to an empty string, numBedrooms and numBathrooms to zero, price to zero, and squareFeet to zero.
Parameterized Constructor: This constructor takes arguments for address, numBedrooms, numBathrooms, price, and squareFeet.
Methods:
The House class should contain the following methods:
Getters and Setters for address, numBedrooms, numBathrooms, price, and squareFeet.
A method calculatePricePerSqFt that returns the price per square foot ie price divided by squareFeet
Driver Program:
Create a main program driver program that does the following:
Prompts the user to enter the address, number of bedrooms, number of bathrooms, price, and total area in square feet for a new house.
Creates a new House object using the parameterized constructor and the user's input.
Prints out the house's address, number of bedrooms, number of bathrooms, price, total area, and price per square foot using the calculatePricePerSqFt method
Prompts the user to update the price of the house. Calls the setPrice method with the user's input, then prints out the house's new price and updated price per square foot. Be sure to format the price for currency.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
