I am trying to start the odometer reading at 0 to start with, but I want it to increase everytime the user inputs MilesDriven. I can't seem to get it to work...any ideas?
//Paul Baker
//TRCC Intermediate C++
//Assignment 3, Odometer
#include <iostream>
using namespace std;
class Odometer
{
public:
void OdometerReset();
void MPG();
int MilesDriven;
int MilesPerGallon;
int OdometerReading;
};
int main()
{
while (true)
{
Odometer TodaysMiles;
cout << "Please enter Miles Driven: ";
cin >> TodaysMiles.MilesDriven;
cout << endl;
TodaysMiles.MPG();
cout << endl;
}
}
void Odometer::MPG()
{
double TotalMPG;
MilesPerGallon = 200;
TotalMPG = MilesPerGallon / (MilesDriven * 1.0);
OdometerReading += MilesDriven;
cout << "Miles Per Gallon is: " << MilesPerGallon << endl;
cout << "Fuel Efficiency is: " << TotalMPG << endl;
cout << "Odometer Reading is: " << OdometerReading << endl;
}