//main function with Data call and Loop statements.
int main()
{
//Answer Key.
string answer="abcdefabcdefabcdefab";
int i=0;
double max=0.0,min=100.0,sum=0.0;
//Variables
int student_num;
cout<<"Please enter number of students to be graded :";
cin>>student_num;
cout<<"For each of the following students,enter the StudentID and answer details :"<<endl;
//Student ID and Answer Input
while(i<student_num)
{
cout<<"ERROR in the studentID number.\nPlease re-enter student ID number for student "<<i+1<<" :";
cin>>StudentID;
cout<<"Please re-enter student's answers:";
cin>>input;
}
}
// Percentage and Grade calculator.
int correct=0;
for(int j=0;j<input.size() && j<answer.size();j++)
{
//Cout with Function call.Outputs Grade.
cout<<" Score "<<score<<"% "<<tmpscore(score)<<endl;
//Maximum and Minimum score calculator.
if(score > max )
max=score;
if(score < min )
min=score;
sum = sum+score;
i++;
}
//Statistics, Average score calulator and min,max outputter.
cout<<"Statistics:"<<endl;
cout<<" Average score = "<<sum/student_num<<endl;
cout<<" Maximum score = "<<max<<endl;
cout<<" Minimum score = "<<min<<"%"<<endl;
system("pause");
return 0;
}
// Grade caller. Funtion
string tmpscore(double x)
{
if(x>=90)
cout<<"grade = A "<<endl;
else if(x >=80 && x <90)
cout<<"grade = B "<<endl;
else if(x >=70 && x <80)
cout<<"grade = C "<<endl;
else if(x >=60 && x <70)
cout<<"grade = D "<<endl;
else if(x >=50 && x <60)
cout<<"grade = E "<<endl;
else if(x < 50 )
return "grade = F ";
}
void displaymessage ()
{
int i=0;
cout<<"ERROR: The student ID is invalid. Please re-enter student ID number.";
cout<<"\nStudent "<<i+1<<""" ID: ";
}