this is the exact instructions:
"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.
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"
ive done a lot of it so far but i cant figure out how to do a few things. I cant figure out how to list how many people got question 1 right, question 2 right, etc. and im having trouble finding the highest/lowest/ and mean scores.
i didnt use any arrays on this project, and im not sure if it would be better to use an array for this kind of thing or if i can still make it work without any arrays.
this is the code i have so far:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
ifstream infile("grade_data.txt");
string grades, key;
string t1;
int temp;
int main()
{
if (!infile)
{
cout << "Error opening file\n\n";
system("pause");
}
else
cout << "File Successfully Opened\n\n";
infile >> key;
string a1 = key.substr(0,1);
string a2 = key.substr(1,1);
string a3 = key.substr(2,1);
string a4 = key.substr(3,1);
string a5 = key.substr(4,1);
string a6 = key.substr(5,1);
string a7 = key.substr(6,1);
string a8 = key.substr(7,1);
string a9 = key.substr(8,1);
string a10 = key.substr(9,1);
cout<<endl;
infile >> grades;
while (!infile.eof())
{
temp++;
string b1 = grades.substr(0,1);
string b2 = grades.substr(1,1);
string b3 = grades.substr(2,1);
string b4 = grades.substr(3,1);
string b5 = grades.substr(4,1);
string b6 = grades.substr(5,1);
string b7 = grades.substr(6,1);
string b8 = grades.substr(7,1);
string b9 = grades.substr(8,1);
string b10 = grades.substr(9,1);
int results=0;
if (a1==b1)
results++;
if (a2==b2)
results++;
if (a3==b3)
results++;
if (a4==b4)
results++;
if (a5==b5)
results++;
if (a6==b6)
results++;
if (a7==b7)
results++;
if (a8==b8)
results++;
if (a9==b9)
results++;
if (a10==b10)
results++;
int g;
g=results*10;
cout<<"Student "<<temp<<": Made: "<<results<<" Missed: "<<10-results<<" Grade: "<<g<<"%\n";
infile >> grades;
}
cout<<endl;
system("pause");
}