Question: Modify the code from last week's Gradebook assignment with Arrays and Functions, to include a two - dimensional array for 3 students and 5 test
Modify the code from last week's Gradebook assignment with Arrays and Functions, to include a twodimensional array for students and test scores per student.
Adjust the logic to drop the high score and the low score and average the remaining three scores for each student. The grade is based on the average of the middle scores.
All data is read in from the keyboard.
Two global constants may be utilized: one for number of students and one for number of tests.
Display in a table format the student's name, test scores, average, and grade. Include a header in the table to label each column respectively.
Use iomanip and setw to format the output.
Main should consist of variable declarations and function calls. This means the for loops to process the arrays resides in the functions, not in main.
Here is my initial code, having issues trying to implement the bool validation.
#include
#include
#include
using namespace std;
void getStudentInfostring& name, int& t int& t int& t;
void displayResultsstring name, float avg, char grade;
int getTestScore;
float calcAvgint t int t int t;
bool isValidint num, int min, int max;
string getName;
char assignGradefloat avg;
int main
char choice, finalGrade;
string fullName;
int test test test;
float average;
do
getStudentInfofullName test test test; replaces the four following lines of code
fullName getName;
test getTestScore;
test getTestScore;
test getTestScore;
average calcAvgtest test test;
finalGrade assignGradeaverage;
displayResultsfullName average, finalGrade;
cout
t Do you wish to restart the program? YN
;
cin choice;
cout endl;
cin.ignore;
while choice Y && choice y && choice N && choice n
cout Invalid choice, please enter Yy Nn endl;
cin choice;
while choice Y choice y;
cout You have quit the program
Thank you and come again!
;
return ;
void getStudentInfostring& name, int& t int& t int& t
name getName;
t getTestScore;
t getTestScore;
t getTestScore;
void displayResultsstring name, float avg, char grade
cout setw setfill endl;
cout Norco College endl;
cout CIS: Intro to Programming with C
;
cout Student Averages endl;
cout setw setfill endl;
cout showpoint fixed setprecision;
cout name : avg ; Grade: grade endl;
int getTestScore
int score,
min
max ;
cout Enter a test score:t ;
cin score;
while isValidscore min, max validation while loop
cout Try again, please enter a valid test score t;
cin score;
return score; returns an integer score for test scores
float calcAvgint t int t int t
float avg;
avg staticcastt t t;
return avg;
bool isValidint num, int min, int max
if num min num max
return false;
else
return true;
string getName
string name;
cout Input the student name: ;
getlinecin name;
return name;
char assignGradefloat avg
const float AGRADE ;
const float BGRADE ;
const float CGRADE ;
const float DGRADE ;
const float FGRADE ;
char grade;
if avg AGRADE
grade A;
cout Excellent! You earned an grade endl;
else if avg BGRADE
grade B;
cout Good job! You earned a grade endl;
else if avg CGRADE
grade C;
cout Nice Work. You earned a grade endl;
else if avg DGRADE
grade D;
cout Below average work. You earned a grade endl;
else if avg FGRADE
grade F;
cout You failed the course, You earned a grade endl;
return grade;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
