No idea how to do this conversion. Can anyone help?

Oct 7, 2015 at 12:39am
Hey, so I am new to c++ trying to learn on my own, and I am across a problem that really has me stuck. So I am supposed to ask the user for how much cubic feet of water is used. Then, the program is supposed to convert that number into gallons and ounces. If you could help me that would be great. The code I have so far is:

#include <iostream>
using namespace std;

int main()
{
const double gallons_per_cubicFoot = 7.4805;
const int ounces_per_gallon = 128;
int cubic_feet, totalGallons;
double ounces;

cout << "Enter the number of cubic_feet of water used: ";
cin >> cubic_feet;

cout << "The number you entered is " << cubic_feet << endl;

totalGallons = gallons_per_cubicFoot * cubic_feet;

cout << "The total number of gallons is: " << totalGallons << endl;

ounces =

cout << "The number of total ounces is: " << ounces << endl;


return 0;

}
Oct 7, 2015 at 1:20am
closed account (48T7M4Gy)
ounces = ounces_per_gallon * totalGallons
Oct 7, 2015 at 1:25am
That's what I thought, however, I'm supposed to get an answer of 62, which I have no idea how to. So I believe my code must be incorrect
Oct 7, 2015 at 1:30am
closed account (48T7M4Gy)
So what did you have as the formula?( At the moment ounces = means nothing, in fact it won't run. )
Oct 7, 2015 at 1:32am
closed account (48T7M4Gy)
Also, it might be US gallons vs Imperial gallons ?
Oct 7, 2015 at 1:35am
closed account (48T7M4Gy)
Also, show us what your input and output is. Otherwise it's pretty much impossible to take this any further.
Topic archived. No new replies allowed.