Note: This program is designed for incremental development. Complete each step and submit for grading before starting th

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Note: This program is designed for incremental development. Complete each step and submit for grading before starting th

Post by answerhappygod »

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 wall height, wall width, and cost of one paint can (doubles). Calculate and output the wall's area to one decimal place using cout << fixed << setprecision(1) << "Wall area: " << wallArea << " sq ft" << endl;. Submit for grading to confirm 1 test passes.
Ex: If the input is:
the output is:
Step 2 (2 pts). 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.
Ex: If the input is:
the output is:
Step 3 (2 pts). 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.
Ex: If the input is:
the output is:
Step 4 (4 pts). 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.
Ex: If the input is:
the output is:
Wall area: 64.0 sq ft
Paint needed: 0.183 gallonsCans needed: 1 can(s)Paint cost: $49.20Sales tax: $3.44Total cost: $52.64
(Q2)
Part 1
Given 4 integers, output their product and their average, using integer arithmetic. C++ please
Ex: If the input is:
8 10 5 4
the output is:
1600 6
Note: Integer division discards the fraction. Hence the average of 8 10 5 4 is output as 6, not 6.75.
Note: The test cases include four very large input values whose product results in overflow. You do not need to do anything special, but just observe that the output does not represent the correct product (in fact, four positive numbers yield a negative output; wow).
Submit the above for grading. Your program will fail the last test cases (which is expected), until you complete part 2 below.
Part 2
Also output the product and average, using floating-point arithmetic.
Output each floating-point value with three digits after the decimal point, which can be achieved by executingcout << fixed << setprecision(3);once before all other cout statements.
Ex: If the input is:
8 10 5 4
the output is:
1600 6
1600.000 6.750
Note that fractions aren't discarded, and that overflow does not occur for the test case with large values.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply