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

2.25 Ch 2 Program: Painting a wall (C++) (1) Prompt the user to input a wall\'s

ID: 3749313 • Letter: 2

Question

2.25 Ch 2 Program: Painting a wall (C++) (1) Prompt the user to input a wall's height and width. Calculate and output the wall's area. (4 pts) Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear as output when the program runs. Enter wall height (feet): 12.0 Enter wall width (feet): 15.0 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. (4 pts) Enter wall height (feet); 12.0 Enter wall width (feet): 15.0 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 all Hint Use a math function to round up to the nearest gallon. (4 pts) Enter val1 height (feet): 12.0

Explanation / Answer

#include<iostream>

#include<math.h>

using namespace std;

int main()

{

double height,width;//variable declarations

//reading input

cout<<"Enter wall height (feet):";

cin>>height;

cout<<"Enter wall width (feet):";

cin>>width;

//calculating area

double area = height*width;

//displaying output

cout<<"Wall area :"<<area<<" square feet"<<endl;

//finding paint needed

double p = 1.0/350.0;

double paint = area*p;

//displaying output

cout<<"Paint needed :"<<paint<<" gallons ";

cout<<"Cans needed :"<<ceil(paint)<<" can(s) ";//printing by round off to large number

return 0;

}

output1:

Enter wall height (feet):10
Enter wall width (feet):20
Wall area :200 square feet
Paint needed :0.571429 gallons
Cans needed :1 can(s)


Process exited normally.
Press any key to continue . . .

output2:

Enter wall height (feet):100
Enter wall width (feet):200
Wall area :20000 square feet
Paint needed :57.1429 gallons
Cans needed :58 can(s)


Process exited normally.
Press any key to continue . . .