submit itec320-01 clusters.adb
Your assignment is to write a program called clusters
that does some analysis of an increasing sequence of positive integers.
You are to recognize clusters of integers and output
information on each cluster and on all clusters.
The integers might represent, for example, the times at which some event occurs, and
the events might occur in clusters.
Sample Run:
Assume that this sample input data is in the file p1.dat:
4 15 16
1016 1017
1020 1021 1022
1110 1111 1113 1116 1125 1126 1136
100000000 100000001
0
Assume that the program is executed, with the input redirected from the input file, as
follows:
clusters < p1.datThen this will be the resulting output:
Cluster 1
Size: 3
Range: 12
Average gap size: 6.00
Cluster 2
Size: 12
Range: 120
Average gap size: 10.91
Cluster 3
Size: 2
Range: 1
Average gap size: 1.00
Number of clusters: 3
Largest size: 12
Second largest size: 3
Average of average gap sizes: 5.97
Weighted average of average gap sizes: 9.50
Input specification:
get). put) clusters.adb
get and put.
Do NOT use a file that is named in your program for input.
Grading criteria: When grading I will check the following specifications:
For your own benefit, you
should test your program using a set of test cases that are stored in a file.
To cause standard input to read from a file you must use redirection.
For example, to cause it to read from a file named myData.txt,
you would enter the following on the command line:
clusters < myData.txt
Please remember that if you put your data in a file, then end_of_file is automatically detected after the last character in the file has been reached - you do NOT put a control-D or a control-Z into the file! Also remember that your data file needs to be created using the same operating system that you use to create your file.
Marking End of File on Interactive Input: If you want to test your program with data from the keyboard (ie with standard input reading from the keyboard), then you will need some way of signaling the end of the input. We call this signaling end of file even though there is actually no file when you do interactive input.
The way you signal end of file depends on the operating system.
On unix/linux systems, the function
end_of_file returns true when you type ^D (ie hold down control
and press D, aka control-D) on a separate line.
On MS Windows systems, end_of_file returns true when you
type, on a separate line, ^Z followed by an enter.
Please remember that when reading from a file,
the OS recognizes when the input is at the end of file,
and so you do NOT put a control-D or control-Z into the file!
Of course, to run your program so that standard input reads from the keyboard, you simply
enter its name as a command (eg clusters).
Style: Your program should follow my style guide. In particular, please note the use of consistent indentation, named constants, and descriptive constant and variable names. Please remember that the first thing in any program file should be a comment that gives a brief overview of what the file contains (and should do). Also remember to keep your lines less than 80 characters long. Not only does this mean that printouts won't run off the side of the page, but it also makes your programs look neater on an 80 column wide xterm window (a popular size). Please ask if you have questions about style.
Submission:
Use the submit command to turn your
program in for grading. You may submit
as many times as you like, but only the last submission
is kept. In particular, be aware that since only the last submission is
kept, if the last one is late, then your assignment is late and will thus
receive a late penalty. Also remember that you must be on
rucs2 for submit to work. To submit your work for grading
do the following:
submit itec320-01 clusters.adb
| Next assignment |