Objective: Keep practicing file reading, while loops and if/else conditions. For
ID: 3636927 • Letter: O
Question
Objective: Keep practicing file reading, while loops and if/else conditions.For each requirement, before righting code, think how a program can solve the problem,
for example (not necessarily related to this homework) :
? to calculate the highest score you cannot “see which one is highest”, you need to
compare each score with the highest, if the new one is higher ? highest=score
? to count the number of lines you cannot “see how many lines are in the file”, you need
to use a variable as a counter, and increment it every time you read a new valid score
Instruction:
In this assignment you are to write a program that reads student IDs and scores from a file
whose format is as following:
2369
1188
4786
6846
1695
70
40
97
70
98
94
95
62
94
14
?
?
?
?
Each line starts with the student ID of a student, followed by 5 grades.
The student ID is a 4 digit number greater than 1000.
The number of lines is unknown
Consider the grades to be floating numbers
The file is in “/ece/www/ism2008/hw4/scoresHw4b.dat”
For each student:
calculate and print the average grade;
/*THINK! Print average for each student...inside or outside a loop? */
Produce as output:
- SID and average score of each student
- SID and average score of the student who has the highest average grade.
If multiple students have the same highest grade outputting one is
sufficient.
87
90
43
87
37
93
59
47
93
46
17
6
92
17
82