Gas Mileage Problem
Gas Mileage Problem
Your friend just bought a car. You look at the car in amazement.
"This made it around the block?"
You politely compliment the car then ask, "What kind of gas mileage does it get?"
Your friend replies, "I have no idea, how can I figure that out?"
Before you continue with this lesson, try to write down step-by-step instructions for your friend to follow to calculate the miles per gallon for the car. This is an algorithm for calculating MPG.
Hints:
- You do not need to know how many gallons the tank holds.
- You may assume that if you fill the tank until it stops automatically, the full tank will always be the same amount.
- Filling the tank, then driving until it’s empty is not “user friendly.”
Test your algorithm by walking through all of the steps on paper. Write down some sample numbers and do all of the calculations.
Now look at the algorithm.