The last part of this code I need the "cans" to be a whole number. I don't know how to change it What I have right now below: #include #include // Note: Needed for math functions in part(3) #include // For setprecision using namespace std; int main() { double wallHeight; double wallWidth; double wallArea; cout << "Enter wall height (feet):" << endl; cin >> wallHeight; // FIXME (1): Prompt user to input wall's width cout << "Enter wall width (feet):" << endl; cin >> wallWidth; // Calculate and output wall area wallArea = wallHeight * wallWidth; // FIXME (1): Calculate the wall's area cout << fixed << setprecision(2) << "Wall area: " << wallArea << " square feet" << endl; // FIXME (1): Finish the output statement // FIXME (2): Calculate and output the amount of paint in gallons needed to //paint the wall cout << fixed << setprecision(2) << "Paint needed: " << wallArea/350 << " gallons" << endl; // FIXME (1): Finish the output statement // FIXME (3): Calculate and output the number of 1 gallon cans needed to // paint the wall, rounded up to nearest integer cout << "Cans needed: " << round(wallArea/350) << "can(s)" << endl; return 0; }
The last part of this code I need the "cans" to be a whole number. I don't know how to change it
What I have right now below:
#include <iostream>
#include <cmath> // Note: Needed for math functions in part(3)
#include <iomanip> // For setprecision
using namespace std;
int main()
{
double wallHeight;
double wallWidth;
double wallArea;
cout << "Enter wall height (feet):" << endl;
cin >> wallHeight;
// FIXME (1): Prompt user to input wall's width
cout << "Enter wall width (feet):" << endl;
cin >> wallWidth;
// Calculate and output wall area
wallArea = wallHeight * wallWidth; // FIXME (1): Calculate the wall's area
cout << fixed << setprecision(2) << "Wall area: " << wallArea
<< " square feet" << endl;
// FIXME (1): Finish the output statement
// FIXME (2): Calculate and output the amount of paint in gallons needed to
//paint the wall
cout << fixed << setprecision(2) << "Paint needed: " << wallArea/350
<< " gallons" << endl; // FIXME (1): Finish the output statement
// FIXME (3): Calculate and output the number of 1 gallon cans needed to
// paint the wall, rounded up to nearest integer
cout << "Cans needed: " << round(wallArea/350) << "can(s)" << endl;
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images