Gasoline Mileage Log

November 2, 2012

I keep a log of gasoline mileage on a 3-by-5 card in the glovebox of my car. Recent entries on the card look like this:

   Date    Mileage  Miles  Gals MPG
----------  ------  -----  ----  --
08/18/2012  107679  290.8  13.1  22
08/26/2012  107934  255.3  10.4  24
09/05/2012  108197  262.9  12.2  22
09/16/2012  108518  321.7  13.8  23
10/02/2012  108762  243.5  12.2  20
10/09/2012  109028  265.6  11.5  24
10/18/2012  109306  278.1  12.4  22
10/27/2012  109589  283.3  11.1  26

Your task is to read a file containing mileage and gallons, compute miles per gallon, and produce an output similar to that shown above. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

Pages: 1 2

Follow

Get every new post delivered to your Inbox.

Join 627 other followers