Learn to Program Step-by-Step

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

Like us on Facebook:

OER: Open Educational Resource
Creative Commons License Author: Janet E. Joy; Publisher: Zebra0.com
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License
Creative Commons Attribution-NonCommercial 4.0 International License
Last modified: April 14 2016 14:23:47.