|
Winter Quarter 1998-1999
S-331, 277-7339
PurposeIn this lab, you will write a C++ program that reads input from an input file, computes some statistics, and writes the results to an output file. In doing this lab assignment you should learn how to use selection statements effectively and read from and write to files. In addition, the assignment is designed to give you more experience with programming design and other basic operations in C++. AssignmentIn 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 forth column indicates the price paid for the gas. Write a program that will read the data file, calculate a number of statistics, and display them on the screen. Your output should include the following statistics:
In addition, you should include any additional statistics required to answer the questions listed below.
Assume the following: Winter = {Dec, Jan, Feb}, Spring = {Mar, Apr, May}, Summer = {Jun, Jul, Aug}, Fall = {Sep, Oct, Nov}. Programming consideration: It is always good in program design to consider potential modifications that may be required a some later date. Be sure to keep this in mind when designing your program. Lab reportThe lab report should be self-contained. That is, it should be possible for someone to understand what you did and why without seeing anything other than your report. Your report should include:
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. The lab report is due at 4:00pm, Monday, Jan. 11, 1999, though you are encouraged to submit it sooner if you can. If you have any questions, consult the instructor. This page was created by Dr. Christopher C. Taylor, copyright 1998. |