Updating An Array In A Grading Program

OBJECTIVE OF THE PROGRAM

The program will grade a series of exams and then print a grade report for students in a course.

Input: An instructor has a class of students each of whom takes a multiple-choice exam with 10 questions. For each student in the class, there is one line in the input file. The line contains the answers that student gave for the exam. The input file named "grade_data.txt" will have the following format:

line 1: the key for the exam (e.g.)

bccbbadbca

lines 2-n:

a set of answers. You know you are done when you get to a line with no data.

Note: You will not know in advance how many exams you have to grade and you don't need to store the exam answers in your program.

Processing: The program is to read the input file and grade each exam and print out the score for that exam. You will also keep track of how many students earned each score (0-10) and print a report after the grading.

Output: Here is an example of how the output might appear. You will write the report to an output file named "grade_report.txt"

Student 1 - 8
Student 2 - 10
Student 3 - 1
etc.

Final Report
------------

10 - 4
9 - 2
8 - 3
.
.
1 - 3
0 - 0

high score - 10

low score - 1

mean score - 6.25

What I am having trouble with is the second part of the program. I have already figured out each grade for each student. The part I am having trouble with is updating the array every time that it gives me a student score so that I know how many people made a 10, how many made a 9, etc. If someone could please help me out on how to do that it would be well appreciated.
Last edited on
You could have an integer for each grade. example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
int grade10;
int grade9;
int grade8;
int grade7;
int grade6;
int grade5;
int grade5;
int grade3;
int grade2;
int grade1;
if(studentScore == 10)
     grade10++;
if(studentScore == 9)
     grade9++;
if(studentScore == 8)
     grade8++;
if(studentScore == 7)
     grade7++;
if(studentScore == 6)
     grade6++;
if(studentScore == 5)
     grade5++;
if(studentScore == 4)
     grade4++;
if(studentScore == 3)
     grade3++;
if(studentScore == 2)
     grade2++;
if(studentScore == 1)
     grade1++;

or even better, you could make an array of the grades and use that.
Topic archived. No new replies allowed.