submit itec320-01 intsets.adb
Update 9/10/09:
Your assignment is to write a program called intsets
that does some analysis of sets of integers.
For each set you are to display the
Sample Run:
Assume that this sample input data is in the file p1.dat:
2 6 4 4 10 40 20 29 3 -1 -2 -2 1 5 0Assume that the program is executed, with the input redirected from the input file, as follows:
intsets < p1.datThen this will be the resulting output:
Set 1
Size: 2
Average: 5.00
Second largest: 4
Set 2
Size: 4
Average: 24.75
Second largest: 29
Set 3
Size: 3
Average: -1.67
Second largest: -2
Set 4
Size: 1
Average: 5.00
Overall Average: 10.47 8.27
Largest second largest: 29
Input specification:
get). put) intsets.adb
Your program should read from standard input and write to standard output,
which is the default for 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:
intsets < 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 intsets).
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 intsets.adb
| Next assignment |