98.7k views
5 votes
Write a program to calculate the cost to paint a wall. Amount of required paint is based on the wall area. Total cost includes paint and sales tax.

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.

Read from input wall height, wall width, and cost of one paint can (doubles). Calculate and output the wall's area to one decimal place using System.out.printf("Wall area: %.1f sq ft\\", area)

1 Answer

6 votes

Final answer:

To calculate the cost to paint a wall, you need to get the wall's dimensions and the cost of one paint can. Calculate the wall's area and the amount of paint needed. Calculate the total cost of the paint and add the sales tax to get the final cost.

Step-by-step explanation:

To calculate the cost to paint a wall, you need to get the wall's dimensions (height and width) and the cost of one paint can. Start by calculating the wall's area by multiplying its height and width. Then, calculate the amount of paint needed by dividing the wall's area by the coverage of one paint can. Next, find the total cost of the paint by multiplying the amount of paint needed by the cost of one paint can. Finally, calculate the sales tax by multiplying the total cost of the paint by the rate of sales tax. Add the sales tax to the total cost to get the final cost to paint the wall.

User Sergey Kucher
by
7.3k points