Question: I need help fixing my code. Instructions Write a program to calculate students average test scores and their grades. You may assume the following input

I need help fixing my code.

Instructions Write a program to calculate students average test scores and their grades. You may assume the following input data:

Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63 Use three arrays: a one-dimensional array to store the students names, a (parallel) two-dimensional array to store the test scores, and a parallel one-dimensional array to store grades.

Your program must contain at least the following functions:

a function to read and store data into two arrays a function to calculate the average test score and grade a function to output the results. Have your program also output the class average. Use the following scale to determine the letter grade: 90%100%, A; 80%89.99%, B; 70%79.99%, C; 60%69.99%, D; and 0%59.99%, F . My Code:

#include using namespace std;

string names[10]; int scores[10][5]; char grades[10]; char assignGrade(float avg); void read(string names[],int scores[10][5]) { cout<<"Input:"< for(int i=0;i<10;i++) { cin >> names[i]; for(int j=0;j<5;j++) cin >> scores[i][j]; } }

void calculate(int scores[10][5], char grades[10]) { for(int i=0;i<10;i++) { float sum=0; for(int j=0;j<5;j++) { sum+=scores[i][j]; } float avg=sum/5; grades[i]=assignGrade(avg); } }

void display(string names[],char grades[]) { cout<<" Output:"< for(int i=0;i<10;i++) { cout< } }

char assignGrade(float avg) { if(avg>=90 && avg<=100) return 'A'; else if(avg>=80 && avg<=89.99) return 'B'; else if(avg>=70 && avg<=79.99) return 'C'; else if(avg>=60 && avg<=69.99) return 'D'; return 'F'; }

int main() { read(names,scores); calculate(scores,grades); display(names, grades); } When it runs it outputs: : F : F : F : F : F : F : F : F : F : F I am also missing: Class average: 70.94 Johnson 85.00 83.00 77.00 91.00 Clark 60.00 85.00 45.00 39.00 Sunny 79.00 85.00 28.00 93.00

Expected output (keywords):

Class average: 70.94 Johnson 85.00 83.00 77.00 91.00 Clark 60.00 85.00 45.00 39.00 Sunny 79.00 85.00 28.00 93.00

Please post text, not just images.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!