Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a java program. Flooring Quote Calculator For this project, you will create an object-oriented program that calculates a price quote for installing different types of

a java program.

Flooring Quote Calculator For this project, you will create an object-oriented program that calculates a price quote for installing different types of flooring in a house. Your program must allow the user to enter the homeowners information, the number of rooms where they want new flooring installed, the area of each room, and the type of flooring for each room. Your program will then calculate and print the installation cost, flooring cost, and total cost. Your program will need to use a House class that contains information about the home and home owner. An inner class, Room, will maintain the dimension and flooring options selected. The House object will maintain an array of Room objects. Each Room object will aggregate one Floor object, which will be used to calculate prices.

Carpet is $6.00 per square foot

Tile is $5.00 per square foot

Hardwood is $7.00 per square foot

image text in transcribed

image text in transcribedimage text in transcribed

package Assignment;

public abstract class Floor {

private double sqft;

public double getSqft() {

return sqft;

}

public void setSqft(double s) {

sqft = s;

}

public final double getInstallationCost() {

return 10 * sqft;

}

public abstract double getFlooringCost();

}

Floor Abstract Class (Floor.java) This abstract class is provided and requires no modification or changes by you. The specific floor type classes you will create will extend this class and inherit its public members. It contains: Public setter and getter methods for the class's private sqft field. (This field stores the square footage of flooring for a room) A final public method named getInstallationCost() that calculates and returns the installation cost ($10 per square foot, regardless of flooring type; a double). An abstract getFlooring Cost() method (public, returns a double) that subclasses must define. Carpet, Tile, and Hardwood Classes (Carpet.java, Tile.java, and Hardwood.java) You will create three classes, all of which extend the Floor abstract class. These classes will only contain: A constructor that accepts one int argument (The square footage) and calls the appropriate setter method inherited from the superclass. A definition for the abstract getFlooring Cost() method, which will compute and return the price. o Carpet Flooring Cost = The area (square footage) multiplied by 6.00 Tile Flooring Cost = The area (square footage) multiplied by 5.00 o Hardwood Flooring Cost = The area (square footage) multiplied by 7.00 Room Class (An inner class in House.java) This class must contain only the following: One private Floor field named floor Type One public constructor, that accepts two arguments: o A parameter named arealn (double), which is the area of the room o A parameter named floor Typeln (String) . Based on this value (either "carpet", "tile", or "hardwood") it will create a Carpet, Tile, or Hardwood object and assign it to Room's floor Type field. A public getter method for the floor Type field House Class (House.java) This class must contain only the following: Eight fields, all private o ownerName - A String for holding the homeowner's name. o phoneNumber - A String for holding the homeowner's phone number. o streetAddress - A String for holding the house's street address. o city - A String for holding the house's city. o state - A String for holding the house's state. o zipCode - A String for holding the house's zip code. o rooms - An array of Room objects. o roomIndex - An int that keeps track of what index to place new Room objects in the rooms array. One public constructor that accepts one int argument- numRooms o The numRooms argument is used to instantiate the rooms field with an array of this length. o Assigns empty Strings to the other six fields and assigns zero to roomIndex. Fifteen Methods, all public o Setters and getters for only the ownerName, phone Number, streetAddress, city, state, and zipCode fields (12 methods total) o addRoom (public, returns void) . Accepts two arguments parameters named sqft (double) and fType (String) "sqft" represents the square footage of the room. "fType" is a String containing either "carpet", "tile", or "hardwood". . The method should use the parameters to instantiate a Room object and add it to the next available index in the array (using the roomIndex field). Remember to increment roomIndex after placing the Room object in the array. o getInstallation Cost(public, returns double, no parameters) . This method calculates and returns the total cost of installation. . You'll need to use the Room objects in the rooms array to complete this. o getFlooring Cost(public, returns double, no parameters) . This method calculates and returns the total cost of flooring. . You'll need to use the Room objects in the rooms field to complete this. FlooringCalculator Class (Flooring Calculator.java) This is the class that will use the House class you created. In the main method: . Prompt the user to enter the customer's name, phone number, address, city, state, zip code, and the number of rooms. Instantiate a House object. Supply it with the number of rooms entered by the user. Provide the House object with the customer's data, using the appropriate setter methods. Prompt the user to enter the area (square footage) and flooring type for each room. o You can use "Enter 1 for Carpet, 2 for Tile, and 3 for Hardwood:" or something to that effect for selecting the flooring type. No matter how you implement this, be sure to check for invalid entries. o Provide the House object's addRoom method with the appropriate arguments, so that it can add a Room object to the array of Rooms. Print the customer's information. o Use the getter methods you created in the House object. Print the installation cost o Use the value returned by the House object's getinstallation Cost method. Print the flooring cost o Use the value returned by the House object's getFlooring Cost method. Print the total cost Sum of the two previously returned values

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions