Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(1) Prompt the user to input a wall\'s height and width. Calculate and output th

ID: 3792434 • Letter: #

Question

(1) Prompt the user to input a wall's height and width. Calculate and output the wall's area. (2 pts) Enter wall height (feet): 12 Enter wall width (feet): 15 Wall area: 180 square feet

(2) Extend to also calculate and output the amount of paint in gallons needed to paint the wall. Assume a gallon of paint covers 350 square feet. Store this value using a const double variable. (2 pts) Enter wall height (feet): 12 Enter wall width (feet): 15 Wall area: 180 square feet Paint needed: 0.514286 gallons

(3) Extend to also calculate and output the number of 1 gallon cans needed to paint the wall. Hint: Use a math function to round up to the nearest gallon. (2 pts) Enter wall height (feet): 12 Enter wall width (feet): 15 Wall area: 180 square feet Paint needed: 0.514286 gallons Cans needed: 1 can(s)

have been trying to do for hours!! keep getting the last answer wrong

Explanation / Answer

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
double width, height;
const int VALUE = 350;
cout << "Enter wall height (feet): ";
cin >> height;
cout<<"Enter wall width (feet): ";
cin >> width;
double area = width * height;
cout<<"Wall area: "<<area<<" square feet"<<endl;
double paintNeeded = area/VALUE;
cout<<"Paint needed: "<<paintNeeded<<" gallons."<<endl;
int cans = round(paintNeeded);
cout<<"Cans needed: "<<cans<<" can(s)"<<endl;

return 0;
}

Output:

sh-4.2$ g++ -o main *.cpp                                                                                                                                                                                                                                              

sh-4.2$ main                                                                                                                                                                                                                                                           

Enter wall height (feet): 12                                                                                                                                                                                                                                           

Enter wall width (feet): 15                                                                                                                                                                                                                                            

Wall area: 180 square feet                                                                                                                                                                                                                                             

Paint needed: 0.514286 gallons.                                                                                                                                                                                                                                        

Cans needed: 1 can(s)