Write a program to calculate students average test scores and their grades. You
ID: 3583834 • Letter: W
Question
Write a program to calculate students average test scores and their grades. You may assume the following 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 student names, a (parallel) twodimensional array to store the test score, and a parallel one-dimensional array to store grades. Your program must contain at least the following methods: a method to read and store data into two arrays, a method to calculate the average test score and grade and a method to output the results. Have your program also output the class average. Grade calculation to be computed as follows: Marks Grade 85-100 A 75-84 B 65-74 C 50-64 D <50 F
Explanation / Answer
Program:
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
void displaystudentsGrades(string s[],int m[10][10], string g[]);
main()
{
string students[] = {"Johnson","Aniston","Cooper", "Gupta", "Blair", "Clark","Kennedy","Bronson",
"Sunny","Smith"};
int Marks[10][10]= {{ 85,83,77,91,76 },{ 80,90,95,93,48 },{78,81,11,90,73},{92,83,30,69,87},{23,45,96,38,59},{60,85,45,39,67},{77,31,52,74,83},{93,94,89,77,97},{79,85,28,93,82},{ 85,72,49,75,63}};
string Grade[] = {"82.4 - B","81.2 - B","66.6 - C","72.2 - C","52.2 - D","59.2 - D","63.4-D","90 - A","73.4 - C","68.8 - C"};
displaystudentsGrades(students,Marks,Grade);
}
void displaystudentsGrades(string s[],int m[10][10], string g[])
{
int w=0,z=0;
cout << setw(7) << " Students Name " << setw(7) << " Marks " <<setw(7) << " Grades "<< endl;
cout << setw(7) << "-----------------" << setw(7) << "------------------" << setw(7) << "-----------" << endl;
for(int i = 0; i <10; i++)
{
cout << setw(10) << s[i] << " ";
if(w <10)
{
cout << setw(15) << m[w] << " ";
w++;
}
if(z <10)
{
cout << setw(10) << g[z] << " ";
z++;
}
cout << " ";
}
}
Output:
Students Name Marks Grades
----------------------------------------------------------------
Johnson 85 83 77 91 76 82.4 - B
Aniston 80 90 95 93 48 81.2 - B
Cooper 78 81 11 90 73 66.6 - C
Gupta 92 83 30 69 87 72.2 - C
Blair 23 45 96 38 59 52.2 - D
Clark 60 85 45 39 67 59.2 - D
Kennedy 77 31 52 74 83 63.4-D
Bronson 93 94 89 77 97 90 - A
Sunny 79 85 28 93 82 73.4 - C
Smith 85 72 49 75 63 68.8 – C
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.