A teacher has five students who have taken four tests. The teacher uses the following grading scale to assign a letter grade to a student, based on the average of his or her four test scores. Write a C++ program that uses an array of string objects to hold the five student names , an array of one character to hold the five students� letter grades , and five arrays of doubles to hold each student�s set of test scores and average score. The program should allow the user to enter each student�s name and his or her four test scores . It should then calculate and display each student�s average test score and a letter grade based on the average . Input Validation: Do not accept test scores less than 0 or greater than 100 . Score Letter Grade 90� 100 A 80-89 B 70-79 C 60-69 D 0-59 F. (Please show output)
#include
using namespace std;
int main()
{
string name[5];
char grade[5];
double marks[5][5], sum;
//input the name, and marks of students
for(int i=0;i<5;i++)
{
cout<<"Enter the name of student "<
cin>>name[i];
sum = 0;
for(int j=0;j<4;j++)
{
cout<<"Enter the marks of subject "<
cin>>marks[i][j];
sum += marks[i][j];
}
cout<<"\n";
marks[i][4] = sum/4;
//calculate grade
if(marks[i][4]>=90 && marks[i][4]<=100)
grade[i] = 'A';
else if(marks[i][4]>=80 && marks[i][4]<=89)
grade[i] = 'B';
else if(marks[i][4]>=70 && marks[i][4]<=79)
grade[i] = 'C';
else if(marks[i][4]>=60 && marks[i][4]<=69)
grade[i] = 'D';
else if(marks[i][4]>=0 && marks[i][4]<=59)
grade[i] = 'F';
}
//displaying the grades
for(int i=0;i<5;i++)
cout<<"Grade obtained by "<
return 0;
}//end of main function