Computer Science 121
Assignment 8
Due: December 4, 2001

This time you are to write a program that reads in student exam scores from a file and stores them in an array of integers.   After they have been read in, you should find the average score and the range of scores.  The range is the highest score minus the lowest score.  Display this data on the screen.  Then display all the scores in the file.  You may assume that the number of students is no larger than 40 and that all scores should have values between 0 and 100.

Follow the example in the TestFiles example.  You can either read scores stored on separate lines or use a StreamTokenizer to read several scores on the same line.  Explain in a comment which method you are using.  Remember to count the scores as you read them in.  There should be somewhat fewer than 40 in the file.

To calcualte the average score, you can use a for loop to add up all the scores.  When done, divide by the number of scores.  To find the highest score, start with the first score in the array.  Store it in a local variable, the current high.  Then one by one, compare the rest of the scores with the contents of that variable.  If a higher score is encountered, replace the current high with the latest value.  When you are done, you should have the highest score.  You can find the lowest score similarly.

Use the file, scoreFile.txt, that is listed below.

Finally you should hand in a description of how you went about designing and writing the program. Use a word processor and write this on a separate sheet of paper.

scoreFile.txt

44
67
90
79
65
65
57
90
61
84
76
98
73
72
91
86
54
79
85
78
77
89
89
86
66
74
82
78
72
92
57
65
94
73