Question
Grade Book Modification- C++ Modify the grade book application so that it drops each students lowest score when determing the test scre averages and letter
Grade Book Modification- C++
Modify the grade book application so that it drops each students lowest score when determing the test scre averages and letter grades.
grade book application:
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
char letterGrade(double score);
int main()
{
char names[5][25]; //student names
char grades[5]; //letter grades
double scores[5][4]; //test scores
double avgScore[5]; //average of 4 test scores
for(int i=0;i<5;i++)
{
cout<<"\nEnter student "<<(i+1)<<" name: ";
cin>>names[i];
cout<<"Enter his 4 scores: ";
for(int j=0;j<4;j++)
{
cin>>scores[i][j];
while(scores[i][j] > 100 || scores[i][j] <0)
{
cout<<"\ntest score should between 0 and 100"<<endl;
cout<<"enter test score: ";
cin>>scores[i][j];
}
}
}
//finding average score of each student
//and letter grade
for(int i=0;i<5;i++)
{
avgScore[i] = 0;
for(int j=0;j<4;j++)
avgScore[i] += scores[i][j];
avgScore[i] /= 4;
grades[i] = letterGrade(avgScore[i]);
}
//displaying average test score and letter grade
cout<<"\nStudent Name\tAverage Score\tLetter Grade"<<endl;
for(int i=0;i<5;i++)
{
cout.setf(ios::fixed,ios::floatfield);
cout.precision(2);
cout<<names[i]<<"\t\t"<<setprecision(2)<<avgScore[i]<<"\t\t"<<grades[i]<<endl;
}
return 0;
}
//return letter grade based on the test score
//passed as parameter
char letterGrade(double score)
{
if(score >= 90 && score <=100)
return 'A';
else if(score >= 80 && score <90)
return 'B';
else if(score >= 70 && score <80)
return 'C';
else if(score >= 60 && score <70)
return 'D';
else
return 'F';
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Modified Code Modify the grade book application so that it drops each students lowest score wh...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started