Zebra0

Learn to Program Step-by-Step

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?"

mileage

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.

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 15 2016 15:49:59.