Zebra0.com

algorithms mileageMPG Calculation

MPG Calculation

Gas Mileage Calculation

We have all of the information we need and can now do the calculations. It is helpful if we make up some values and then do calculations with the sample values.
startOdometer: 8,900
finalOdometer: 9,000
gallons: 20

Before you continue: Find the MPG on paper for the example above. Write down every arithmetic operation you perform. (You cannot use the number 100 unless you show where 100 came from.)

We can now write the algorithm as pseudo-code