Program 5, Gradebook
Short Description:
Write a program which given an input file containing scores for a class will compute the grades for each student in the class.
This assignment is worth 50 points.
Goals
When you finish this homework, you should:
- have demonstrated your ability to use loops.
- have demonstrated your ability to use files.
Formal Description
I store my gradebook in a flat file. Each line corresponds to a single student in the class. Your job is to read in this file and compute the grades for all of the students.
The format for the space delimited file is:
- A string representing the student's last name.
- A string representing the student's first name.
- 10 integers representing homework scores, each worth up to 10 points.
- 6 integers representing program scores, each worth up to 50 points.
- Three floating point numbers representing test scores, between 0 and 100%.
- A floating point number representing a final exam score, between 0 and 100%.
- Unfortunately, there are two random floating point values at the end of the line, these values need to be ignored.
An example input file (default.scores) might be:
Student Good 10 10 10 10 10 10 10 10 10 10 50 50 50 50 50 50 1 1 1 1 1 1 1
Student Bad 10 5 0 0 0 0 0 0 0 0 35 20 0 0 0 0 .2 .1 .05 .1 1 1
Student Average 10 7 7 7 7 6 8 9 5 5 50 50 45 45 30 30 .9 .75 .6 .7 .9999 .9999
I compute the class score as a weighted average of the averages of these components. See this page for exact details.
Your program should prompt the user for a base file name. The input file name will be constructed by appending .scores to the base file name, and the output file name will be constructed by appending .grades to the base file name. So for example, if the base file name is Fall16CSCI130, the input file will be Fall16CSCI130.scores and the output file name will be Fall16CSCI130.grades. If the input file does not exist, your program should print an appropriate error message and exit.
For each line in the input file, your program should produce a space delimited line in the output file containing
- The first name
- The last name
- The homework average, rounded to the nearest integer decimal places and printed as a percent with no decimal places followed by a percent sign.
- The program average, rounded to the nearest integer decimal places and printed as a percent with no decimal places followed by a percent sign.
- The test average, rounded to the nearest integer decimal places and printed as a percent with no decimal places followed by a percent sign.
- The final exam score, rounded to the nearest integer decimal places and printed as a percent with no decimal places followed by a percent sign.
- The class average, rounded to one decimal place and printed as a percent.
- The assigned letter grade for the class.
Finally after all students have been processed, print a table indicating
- The total number of students.
- The total number of A grades assigned.
- The total number of B grades assigned.
- The total number of C grades assigned.
- The total number of D grades assigned.
- The total number of F grades assigned.
This table should be well formatted and readable.
An example output file (default.grades) might be:
Good Student 100% 100% 100% 100% 100.0% A
Bad Student 15% 18% 12% 10% 14.8% F
Average Student 71% 83% 75% 70% 77.6% C
Total Students: 3
A 1
B 0
C 1
D 0
F 1
I will test your program with the default files above. I will also test with Students.scores. The output should match Students.grades. I will use additional test files as well.
Required Files
A single source code file.
Submission
Email your final source code file to danbennett360@gmail.com.