The last part of this code I need the gallon round to the nearest number, but it still shows wrong after I apply the round(), I don't know how to change it #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 gallon round to the nearest number, but it still shows wrong after I apply the round(), I don't know how to change it
#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 2 steps with 1 images