Question: plz write the program in java Q1: A Carpet Company has asked you to write an application that calculates the price of carpeting for rectangular
Q1: A Carpet Company has asked you to write an application that calculates the price of carpeting for rectangular rooms. To calculate the price, you multiply the area of the floor (width times length) by the price per square foot of carpet. For example, the area of the floor that is 12 feet long and 10 feet wide is 120 square foot. To cover that floor with carpet that costs $8 per square foot would cost $960. First you should create a class named RoomDimension that has two fields: one for the length of the room and one for the width of the room. The RoomDimension class should have a method that returns the area of the room. Next you should create a RoomCarpet class that has a RoomDimension object as a field. It should also have a field for the cost of the carpet per square foot. The RoomCarpet class should have a method that calculates and returns the cost of the carpet. Below is a UML diagram that shows possible designs and the relationships among classes. Once you have the two classes, write a test program to ask the user to enter the dimensions of a room and the price per square foot of the desired carpeting. Then display the total cost of the carpet. RoomCarpet - Size : Room Dimension - carpetCost : double + RoomCarpet(dim: RoomDimension, cost : double) + getTotalCost(): double + toString: String Room Dimension - length : double |- width : double + Room Dimension(len: double, w: double) + getArea(): double + toString(): String
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
