The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
C++ question
5.10 Program: Painting a wall (C++)
(1) Prompt the user to input a wall's height and width. Calculate and output the wall's area. (Submit for 2 points).
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. (Submit for 2 points, so 4 points total).
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. (Submit for 2 points, so 6 points total).
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)
Â
Â
Â
#include <iostream>
#include <cmath> // Note: Needed for math functions in part (3) using namespace std; int main() {
double wallHeight = 0.0;
double wallWidth = 0.0;
double wallArea = 0.0; cout << "Enter wall height (feet): ";
cin >> wallHeight;
cout << endl; wallWidth = 10.0; // FIXME (1): Prompt user to input wall's width // Calculate and output wall area
wallArea = 0.0; // FIXME (1): Calculate the wall's area cout << "Wall area: " << endl; // FIXME (1): Finish the output statement // FIXME (2): Calculate and output the amount of paint in gallons needed to paint the wall // FIXME (3): Calculate and output the number of 1 gallon cans needed to paint the wall, rounded up to
nearest integer return 0;
}
Â
Attachments:
-----------