Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Example 4: Write a program to calculate the cost to paint a wall. Amount of required paint is based on the wall area. Total cost

Example 4:

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 after using cout << fixed << setprecision(1) << "Wall area:" << wallArea << " sq ft " << endl;. Submit for grading to confirm 1 test passes.

For example, if the input is:

12.0 15.0 29.95

The output is:

Wall area: 180. sq ft

Also, Calculate and output the amount of paint needed to three decimal places. One gallon of paint covers 350 square feet. Submit for grading to confirm 2 tests pass.

For example, if the input is:

12.0 15.0 29.95

The output is:

Wall area: 180.0 sq ft

Paint needed: 0.514 gallons

Also, Calculate and output the number of 1 gallon cans needed to paint the wall. Extra paint may be left over. Hint: Use ceil() to round up to the nearest gallon and convert to an integer. Submit for grading to confirm 4 tests pass.

For example, if the input is:

12.0 15.0 29.95

The output is:

Wall area: 180. sq ft

Paint needed: 0.5142 gallons

Cans needed: 1 can(s)

Lastly, Calculate and output the paint cost, sales tax of 7% and total cost. Dollar values are output with two decimal places. Submit for grading to confirm all tests pass.

For example, if the input is:

8.0 8.0 49.20

The output is:

Wall area: 64.0 sq ft

Paint needed: 0.183 gallons

Cans needed: 1 can(s)

Paint cost: $49.20

Sales tax: $3.44

Total cost: $52.64

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

3. What is the augmented product?

Answered: 1 week ago