Hey guys, about 3 weeks into my first C++ class and I'm writing a program to calculate mpg. I have the code pretty much worked out, I have to keep a running
total of the gallons used, miles driven and total mpg. I have the total mpg and miles driven calculating right, but I'm having trouble with the total gallons. I have to run the program three times with different variables, the total gallons is now calculating the input from outside the loop. Any advice?
[code]
int main(void) {
StartUp ();
float milesdriven; // total miles driven
float endmiles; // ending mileage
float startmiles; // starting mileage
float gallons; // read in the gallons
float totalgallons; // total gallons used
float totalmiles; // total miles driven
float prevmiles; // previous starting mileage
float milespergallon; // Mpg average
float endingmiles;
float milesgallon;
float totalmilespergallon;
cout << "Enter the gallons used (-1 to end): ";
cin >> gallons;
cout << setprecision(2);
cout << fixed;