# MPG Algorithm

### Gas Mileage Algorithm

Miles Per Gallon

The miles per gallon is the number of miles driven, divided by the number of gallons used. For example if you drive 100 miles and use 5 gallons, the MPG is 20.

- In order to find the number of miles driven you will need the starting odometer reading and the final odometer reading.
- To find the number of gallons used you need to start with a full tank, and then see how many gallons it takes to fill it back up.

Algorithm for Finding Miles per Gallon:

- Go to a gas station and fill the car (until the pump clicks off.)
- Write down the odometer reading. We will call this startOdometer.
- Drive until you need gas again.
- Go to a gas station and fill the car (until the pump clicks off.)
- Write down the odometer reading. We will call this finalOdometer.
- Write down how many gallons you put in. We will call this gallons.

Now do the calculation.

Like us on Facebook:
**OER: Open Educational Resource**
Author:

Janet E. Joy; Publisher: Zebra0.com

This work is licensed under a

Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International LicenseCreative Commons Attribution-NonCommercial 4.0 International License

Last modified: January 08 2016 10:54:05.