Help is available for this project from the Help Center in room ECS332, and from the TA (jfan1@gl.umbc.edu)
Project 2 will do an analysis of some undetermined number of positive integers. You will report the number of positive integers, the largest positive integer (the maximum value), the smallest positive integer (the minimum value), the sum of all of the numbers, and their average (to 2 decimal places).
To eliminate the need to test the user's input for validity, I will be providing a data file for you to use as input for your program. This data file contains positive integers. The last value in the file is -1. This is the sentinel value that signals the program to stop getting integers as input.
To use the data file as input for your program, you will use unix redirection. By using redirection, we can have unix fill the stdin buffer from a data file, instead of from the keyboard. The scanf statement that you use in your program will look exactly the same as it would if you were getting your input from the keyboard.
When you run your program, at the unix prompt you will give the following command:
Here is an example of what the data file might look like:
5-Point Bonus Opporunity
Enhance your program to handle the possibilty that there are NO positive
integers in the file -- i.e. the file contains only a -1. In this case,
your output should indicate that the largest value is 0, the smallest
value is 0, the sum is 0, the average is 0.0 and there were 0 integers
entered. Test your program using the file
/afs/umbc.edu/users/d/e/dennis/proj2/proj2B1.dat
Another 5-Point Bonus Opportunity
Enhance your program to accept input from the user (with an appropriate
prompt) as well as from the file. Also enhance your project to ignore 0
and negative numbers other than -1 that are input by the user or appear in
the file. Your program should provide a simple (but polite) error message
to the user which includes the invalid integer. Test your program using
the file /afs/umbc.edu/users/d/e/dennis/pub/cs104/proj2/proj2B2.dat
$ script $ cc proj2.c $ a.out < /afs/umbc.edu/users/d/e/dennis/pub/cs104/proj2/proj2.dat $ exit $ mv typescript proj2.outNow submit your source file (proj2.c) and your output file (proj2.out) using the submit command as discussed in class.
Make sure that your file header comment contains all necessary information including your algorithm. Also sure that you have used one of the indentation styles from the indentation styles handout consistently throughout your program, as well as following the coding standards described in the coding standards handout and as discussed in class.