submit itec320-01 setops.adb
Your assignment is to write a program that analyzes sets of integers.
Here is a sample run of the program.
Assume that this sample input data is in the file
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:
setops < p1.txtThen 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 Average of Averages: 8.27 Largest second largest: 29
For each set you are to display the set's
After processing all of the sets, your program should print a summary:
Grading criteria: When grading I will check the following specifications:
Creating input files: For your own benefit, you should test your program using a set of test cases that are stored in files. Your data file can be created with any editor, but don't use an editor (such as wordpad) that stores characters using 16 rather than 8 bits. Make sure that your editor is not creating a RTF (ie rich text) file. You will want to make sure that you create your data file using the same OS that you use to test your program. When a data file is created on a different OS, the I/O routines may not correctly detect the end of file or end of line white space. You do not need to submit your data file(s).
Your program is to read from what is known as Standard Input.
Do NOT use a file that is named in your program for input.
If you don't specify otherwise, a read from standard input comes from the keyboard.
To cause standard input come from a file, you must use input redirection.
For example, to cause the program to read standard input from a file named
you would enter the following on the command line:
setops < myData.txt
If you are using AdaGIDE, you must tell it to use redirection and to specify the file: use Run/Run Options, check the Redirect box, and enter the name of the file that contains the data. As far as I know, GPS does not allow redirection. Instead you must use a command line.
To read from standard input, your program can simply use a get such as
End of File on Interactive Input:
If you want to test your program by giving it input from the keyboard, then
you will need some way of signaling the end of the input, that is,
signaling end of file (though there is no real file in this case).
The way you signal end of file differs depending on the operating system.
On unix/linux systems, the Ada function
end_of_file returns true when you enter
^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
enter, 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!
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.
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
rucs for submit to work.
To submit your work for grading
do the submit command given at the top of the assignment.