->Homepage
->Schedule
->Courses
-->CS182
-->Tentative Schedule
-->Objectives
-->Quiz 1
-->Lab 1
-->Lab 2
-->Lab 3
-->Lab 4
-->Lab 5
-->Lab 6
-->Lab 7
-->Project
-->CS183
-->CS285
->Course Policies
->Electronic Submission
->Documentation Standards
->Old Exams
->C++ Examples
->MSVC++ Info
->Software
->Support Forum
->Unix Info
->Nature Photos

[Home]
[Rich][Home][Rich]
[Author]
CS182 -- Lab 5: Commute Time

Winter 2003-2004

Now that I'm working the early morning shift, the difference between when I go to work and when I go home is like night and day. -- Peter Medhurst
Overview

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

Procedures

Since June 25, 2002, I have recorded the amount of time it takes me to get to work. The file commute.txt contains my records for commute times. The first few lines of the file are included below:

# Date                    Commute time to work
#                         mm:ss.hs or hh:mm:ss
# If * after time then trip was not direct
# If d after time then had accident or detour
# ...
Tue Jun 25 10:39:06 CDT 2002 19:29.05
Wed Jun 26 10:25:32 CDT 2002 17:58.65
Thu Jun 27 09:42:47 CDT 2002 19:35.10
Fri Jun 28 10:44:14 CDT 2002 37:41.55*

Lines that begin with a # symbol are comments and should be ignored. Comment lines may appear anywhere in the file (not just at the beginning). Each line containing a data point indicates the date of the commute, the time I arrived in my office, and the time required for the commute. Typically the time is indicated in the following format: mm:ss.hs where mm represents minutes, ss represents seconds, and hs represents hundredths of seconds. In a few cases the time is indicated in the following format: hh:mm:ss where hh represents hours.

Two additional characters (* and d) may appear after the time. Typically none of the characters appears; however, any combination of them may appear on a line. The order in which they appear may not be consistent. The meaning of the symbols is given in the comments at the beginning of the file.

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:

  • Average commute time.
  • Average commute time for direct commutes without incident.
  • Earliest arrival time.
  • Average arrival time.
  • Latest arrival time.
Just for Fun

If you are looking for an extra challenge you may want to include other statistics in your results (be sure to meet the minimum requirements before doing extra). There are lots of other things you could find, but here are some ideas:

  • Typical arrival and/or commute time.
  • Most common arrival and/or commute time.
  • Closest two arrival and/or commute times.
  • Standard deviation of arrival and/or commute times.
  • All of the above for departure time. (To simplify things, you may assume that I was never on the road at midnight... I'm not much of a night person anyway.)
  • Which hour of travel provides the shortest/longest commute times on average. (Travelling between x:00 and y:00 (where y=x+1) results in the shortest average commute time.)
  • Etc...
Lab report (due 11:00pm, the day prior to week 6 lab)

Here is a template file to use as a starting point for this report.

The lab report does not need to be self-contained. Your report should include:

  • A brief narrative filled with interesting observations about your experience with this assignment. Your narrative should convince the reader that you were thinking when doing this assignment.
  • An activity log indicating how much time you spent on each phase of the assignment. You should use the format found in the template XML file and report the time in the following categories:
    • Design
    • Coding
    • Debug (before you think it's working)
    • Test (after you think it's working)
    • Writing Report
    • Other
  • Sample program output.
  • Documented source code for your program.

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 XML help video and/or 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.

Acknowledgment

This laboratory assignment was developed by Dr. Chris Taylor.

Last Updated: Thursday, 01-Jan-2015 13:34:25 CST