-
A Car
keeps track of the starting odometer reading, ending odometer reading, and the number of gallons used between readings.
-
The initial odometer reading is specified in the constructor.
-
A method calculateMPG
calculates and returns the miles per gallon for the car.
-
A method fillUp
simulates filling up the tank at a gas station: odometerReading
is the current odometer reading and gallons
is the number of gallons that filled the tank. Save these values in instance variables.
-
With this information, miles per gallon can be calculated. calculateMPG
will calculate the miles per gallon since the last time resetMPG was called.