I am creating a car simulator program and the output for the the fuel level is correct. But the mileage is incorrect. It is displaying mileage: 1 -- Fuel Level: 15 then mileage: 2 -- Fuel Level 14 and so on. In the directions it says:
**The maximum mileage the odometer can store is 999,999 miles. When this amount is exceeded, the odometer resets the current mileage to 0.
To be able to work with a FuelGauge object. It should decrease the FuelGauge object’s current amount of fuel by 1 gallon for every 24 miles traveled. (The car’s fuel economy is 24 miles per gallon.) **
I have gone through my code but I cant seem to find the problem.
> It should decrease the FuelGauge object’s current amount of fuel by 1 gallon
> for every 24 miles traveled.
¿and where are you doing that?
> I have gone through my code but I cant seem to find the problem.
look at your loop in line 15--21
you are going mile by mile, and at each step decrementing the fuel.