Prompt the user to input a wall's height and width. Calculate and output the wall's area. Enter wall height (feet): 12 Enter wall width (feet): 15 Wall area: 180.0 square feet 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 in a variable.

Respuesta :

Answer:

#include<iostream>

using namespace std;

//main function

int main(){

   //initialization

   float wallHeight, wallWidth;

   int temp = 350;

   //print the message

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

     cin>>wallHeight;   //read the input

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

     cin>>wallWidth; //read the input

   float wallArea = wallHeight * wallWidth;   //calculate the wall area

   cout<<"Wall area: "<<wallArea<<" square feet"<<endl;  //display

   float paintRequired = wallArea/temp;   //calculate the paint needed

   cout<<"The amount of paint in gallons needed: "<<paintRequired<<" gallons"<<endl;

   return 0;

}

Explanation:

Include the library iostream for using the input/output instructions.

Create the main function and declare the variables.

Then, display the message on the screen and after that, read the input enter by user and store in the variables wallHeight .

similar, the process happens for the variable wallWidth.

then, calculate the area by using the formula.

[tex]area = height*width[/tex]

and store in the variable wallArea and then, display on the screen.

after that, calculate the paint required to paint the wall in gallon by using the formula.

given that, 1 gallon covers 350 area.

so, the formula is:

[tex]paint needed = \frac{wall area}{350}[/tex]

and store in the variable paintRequired. Then, display on the screen.

ACCESS MORE
ACCESS MORE
ACCESS MORE
ACCESS MORE