Homework 14
Version 1

Due by 8:00 AM on Monday, December 6, 1999

Be aware that this is a first-draft document. Please report any bugs to fleck@cs.hmc.edu.

For this assignment, you must rewrite your code for homework 6, problem 2 (traffic analysis) so that it uses linked lists. Your new program will be named ListTraffic.

Your program will behave exactly like the model solution for homework 6 with three exceptions. First, if there are any illegal values (i.e. values other than 0, 1, 2, or 3) in the input, it will print a warning message. Second, it will do its analysis as if any illegal values were deleted from the input data. Third, after it has finished its analysis, it will print a user-friendly version of the input data in which

Here is an example of what your program's output should look like.


Please enter signal data from traffic sensor below:
1 1 2 3 5 1 1 2 1 0
Warning:  bad values in data.
Length of survey period was 5 minutes.
Total number of vehicles recorded was 3: 2 cars and 1 trucks.
Most full minutes to pass without vehicles was 2 minutes.
Largest number of vehicles to pass in a single minute was 2.

[start] . . C T * . . C . [end]

Specicially, your program should read all the traffic values into a linked list. It should then compute each of the output numbers by passing the linked list of data to an appropriate method. So your program would have methods such as:

I strongly recommend that you first write the methods that read input data and print the user-friendly display of it. Test these methods before you start writing your other methods, so that you know your linked list has been constructed properly.

You can assume that all input values are integers, even illegal ones, are integers. The user will not input floating point numbers, strings, or the like when you are expecting an integer.

You will not be able to reuse the main loops from your homework 6 code, even with slight modifications. Redesign your analysis code from scratch. Don't panic! Your new analysis code should have a much simpler structure than your old analysis code.

Last modified Nov 24 199 for Fall 99 cs5 by fleck@cs.hmc.edu