Write the CarpetService application that provides the quote to estimate the cost to place the carpet for an area.

The application should provide the menu to allow users select one of the following shapes:

1. Rectangle
2. Square
3. Circle
4. Triangle
0. Exit

The program will terminate when users select option 0.

The program will display the message “ Invalid shape” then terminate the program Otherwise, display the menu to allow users select a number to determine the type of carpet with different unit prices

1. Morocco $0.99
2. Soft Collection Santa Rosa $1.65
3. Santa Rosa $2.09
4. Glamorous $2.49

If user types a number that is not in the range 1 – 4, the program will display the message “Invalid type”; then terminate the program

Otherwise, display the cost result on the screen with all the numbers in two decimal digits format As following: (example for a rectangle room 12.5 x 11.25)

Shape: RECTANGLE
Area: 140.63
Selected price: $1.65
Carpet cost: $232.04
Labor: $35.16
Total: $267.20

Instruction: We should have two classes

Class CarpetQuote

  • Data member
    • shape (shape’ s name, for example: RECTANGLE, QUARE, etc)
    • unitPrice (the price of carpet per square feet)
  • Constructor
    • No-argument constructor: shape = “unknown” , unitPrice = 0.0
    • Argument constructor: accept two parameters, int typeOfShape (1, 2, 3, 4) and int price (1,2,3,4): apply selection constructor using if..else or switch statement:
    • Base on typeOfShape (1,2,3,4 ) -> shape’s name
    • Base on price (1,2,3,4) -> unitPrice
  • Method to calculate the carpetCost: carpetCost = area * unitPrice
  • Method to calculate the labor (100 sq-feet -> $25) Labor = area * 25 / 100
  • Method to calculate tax: tax = 8.5% of carpetCost
  • Method to calculate total of the quote: Total = carpetCost + tax + labor
  • Method toString to build the string to display the quote as requested

Class CarpetService

  • Display the menu that allow users to type a number 1 – 4 to select the shape
  • Display the menu that allow users to type a number 1 – 4 to select the carpet type
  • Create an object of CarpetQuote to pass shape type and carpet type in
  • Display the result as requested by call toString method
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.