The program will grade a series of exams and then print a gr

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:

bccbbbdbbb
bccbbadbca
bccbbadbbb

etc.

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 DO NOT 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

NOTES:

The program must be modular, with significant work done by functions. Each function should perform a single, well-defined task. When possible, create re-usable functions. Do not write trivial functions such as a function to read a single value from an input file.

e.g. you should have a function that grades the exam and returns the score when passed the key and and one set of answers.

You should probably have functions that take an array and number of questions as parameters and find the high, low, and mean.

Don\'t calculate the mean, high, and low as you grade the exams.

Note that you have 11 possible scores 0-10.

The number of questions can be a global constant.

Solution

This is the program i have done so far and please do let me know if any errors occurs.

#include <iostream>

#include <fstream>

#include <string>

using namespace std;

int gradeExam(string key, string exam);

int main()

{

string key;

string exam;

int studentGrade;

ifstream infile;

infile.open (\"grade_data.txt\");

infile >> key >> exam;

int index = 0;

while (infile >> exam)

{

++index;

studentGrade = gradeExam(key, exam);

cout << \"Student \" << index << \" - \" << studentGrade << endl;

}

return 0;

}

int gradeExam(string key, string exam)

{

int studentGrade;

   studentGrade = 0;

   for (int i = 0; i < 10; i++)

   {

if (key[i] == exam[i])

studentGrade = studentGrade + 1;

else

studentGrade += 0;

}

return studentGrade;

}

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
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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site