65 761
Assignments Done
99,3%
Successfully Done
In October 2018

Answer to Question #3293 in C++ for Twinkle Godhwani

Question #3293
Assuming that there are 7.481 gallons in a cubic foot, write a program that asks the user to enter the number of gallons and display the equivalent in cubic feet.
Expert's answer
#include #include using namespace std;

int main()
{
double gallons;
cout << "Please enter the number of gallons: ";
cin >> gallons;
if (cin.fail()) {
cout << "Invalid number of gallons." << endl;
return 1;
}

double cubic_feet = gallons / 7.481;
cout << "The number of cubic feet is " << setprecision(3) << cubic_feet <<
endl;

return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions