#include <iostream>
using namespace std;
class Odometer{
double mD;
double fuelEf;
public:
Odometer(){
mD = 0;
fuelEf = 0;
}
void resetMiles(){
mD = 0;
}
void setFuelEfficent(double amount){
fuelEf = amount;
}
void addMiles(double miles){
mD += miles;
}
double getConsumption(){
return mD / 10;
}
double getMiles(){
return mD;
}
double getFuelEfficent(){
return fuelEf;
}
};
int main(){
Odometer t1;
cout << "Initial Odometer: " << endl;
cout << "Miles Driven: " << t1.getMiles()<< endl;
cout << "Fuel Efficency: " <<t1.getFuelEfficent()<< endl;
cout << "Adding 54.5 miles to odometer" <<endl;
t1.addMiles(54.5);
cout << "Miles Driven: " << t1.getMiles()<< endl;
cout << "The consumption rate of 54.5 is: " <<endl;
cout << "Fuel Efficency: " <<t1.getConsumption() << " miles per gallon(MPG)" <<endl;
cout << "Reseting the odometer" << endl;
t1.resetMiles();
cout << "Miles Driven: " << t1.getMiles()<< endl;
return 0;
}
Comments
Leave a comment