3.4k views
1 vote
Program Specifications Write a program to calculate the cost for replacing carpet for a single room. Carpet is priced by square foot. Total cost includes carpet, labor and sales tax. Dollar values are output with two decimals. For example, System.out.printf("Cost: $%.2f", cost);

Note: This program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only a portion of tests pass after each step but confirm progress.
Step 1 (2 pts). Read from input the carpet price per square foot (double), room width (int) and room length (int). Calculate the room area in square feet. Calculate the carpet price based on square feet with an additional 20% for waste. Output square feet and carpet cost. Submit for grading to confirm 1 test passes.
Ex: If the input is:
1.10 15 12
the output is:------------

User Angrykoala
by
7.9k points

1 Answer

4 votes

Final answer:

The student must create a program that calculates the cost of replacing carpet by first determining the area of the room and then accounting for the price per square foot plus waste.

Step-by-step explanation:

The student's task is to create a program to calculate the total cost of carpet replacement, factoring in carpet price per square foot, labor, and sales tax. The first step is to calculate the room area by multiplying the width by the length and then to calculate the cost of the carpet by adding 20% for waste. For example, if the carpet price is $1.10 per square foot and the room is 15 feet in width and 12 feet in length, you would calculate the area (15 x 12 = 180 square feet) and then the total carpet cost (180 square feet * 1.20 (to account for waste) * $1.10). This gives you the total raw cost before labor and tax.

User Benjen
by
7.0k points