Question 2
Design a class named CarpetCalculator to represent a carpet. The class contains:
• A string data field named carpetName that specify the name of the carpet. (example:
Berber, Pile, etc)
• Three double data fields named pricePerSquareMeter, roomLength, and roomWidth.
• A constructor that creates a carpet with the specified name, price, and area (length *
width)
NOTE: name, and price can be hard-coded.
Length and width can be input by user.
• A method named determineTotalCost() that calculates and returns the cost of the carpet.
a.
Draw a UML diagram for the class.
b.
Implement the class (named CarpetCalculator.java).
c.
Write a program named CarpetCalculatorApp.java that creates two
carpetCalculator objects – first is a Turkish carpet object, and second is Persian
carpet object.
Display the cost of both of the carpets.
Input
?
What is the room length (m)?
OK
Cancel
Input
?
6
What is the room width (m)?
OK
Cancel