header

Homework 8

The registrar has asked you to write a program that will generate a report listing the average GPAs for the freshman class, the sophomore class, the junior class, and the senior class. You have been given a file that contains the GPAs for members of these different classes.

Each line of the input file contains data for one student in the form of four characters. The first character indicates the class (0 - freshman, 1 - sophomore, 2 - junior, and 3 - senior). The remaining three characters represent the student's GPA. Though not present in the data, the decimal point is assumed to go after the first of these three characters. (Since the decimal point  is always in the same spot, it is not necessary to actually store it and omitting it reduces the size of the data file size by about 17%.) Here are some examples:

2254 indicates a junior with a GPA of 2.54.
3365 indicates a senior with a GPA of 3.65.
0195 indicates a freshman with a GPA of 1.95.
1075 indicates a sophomore with a GPA of 0.75.

Write a program that reads a file of this type and displays a table showing the number of students in each class and the average GPA for each class. The sample run below illustrates the format that you are to use for the table.

Sample Run