CS182 -- Lab 4: Gas Mileage



->Courses
->CS182
-->Homework
-->Quiz 1
-->Lab 1
-->Lab 2
-->Lab 3
->Lab 4
-->Lab 5
-->Lab 6
-->Project
->Electronic Submission
->Old Exams
->C++ Examples
->MSVC Info
->Software
->Tentative Schedule
->Support Forum
->Course Policies

[Courses]
[Rich][Home][Rich]
[Author]

Winter Quarter 2001-2002

I remember the first time I saw a Dodge Stealth...
I was so disappointed.
Dave Henry

Overview

In this lab, you should become proficient at file I/O.

Procedures

In the summer of 1992 I purchased my first used car. I began with a full tank of gas and 40056.0 miles on the car. The file mileage.txt contains my records for gas purchases. The first few lines of the file are included below:

Date	 Odomtr 	Gallon	Price
 6/22	 40056.0	 0.000	 0.00
 7/ 8	 40459.2	10.003	10.69
 7/ 8    40814.4	 7.995	 9.75
 7/ 9	 41140.9	 7.274	 7.99

As suggested by the column headings, the first column indicates the date the purchase was made. The second column indicates the odometer reading at the time the car was filled. The third column indicates the number of gallons of gas purchased, and the fourth column indicates the price paid for the gas.

Write a program that will read the data file, calculate a number of statistics, and write them to an output file. Your output file should include the following statistics:

  • Total number of miles between when the car was purchased and the last gas purchase.
  • Total amount of money spent on gas.
  • Gas mileage.
  • Average miles per gas purchase.

Lab report (due 11:00pm, the day prior to week 6 lab)

The lab report should be in your own words and self-contained. By self-contained I mean that it should be possible for someone to understand what you did and why without seeing anything other than your report. Your report should include:

  • Purpose (educational objectives)
  • Problem Statement
  • Procedure (the steps you used to design your program, reasons for your design decisions, etc.)
  • Documented source code for your program.
  • Discussion (sample program output, answers to any questions, problems you encountered (and how they were overcome), etc.)
  • A summary of your activity log indicating how much time you spent on each phase of the assignment. Please report the time in the following categories:
    • Design
    • Coding
    • Debug (before you think it's working)
    • Test (after you think it's working)
    • Documentation
    • Other
  • Conclusions (what you learned, suggestions of how the assignment could be improved, things you would have done differently, etc.)

As with any report you submit, correct spelling and grammar are required. In addition, your report should be submitted electronically following the Electronic submission guidelines. (You may wish to consult the sample report before submitting your report.) Be sure to keep copies of all your files, in case something gets lost. It may be wise to keep a diskette backup as well.

Your grade will depend on quality of design, clarity of code and documentation, as well as whether your program produces the correct results. If you have any questions, consult your instructor.

© 2001 Dr. Christopher C. Taylor Office: CC-27C Phone: 277-7339 Last Updated: November 28, 2001
I am responsible for all content posted on these pages; MSOE is welcome to share these opinions but may not want to.