(Data processing) Your professor has asked you to write a C++ program that deter
ID: 3640207 • Letter: #
Question
(Data processing) Your professor has asked you to write a C++ program that determines grades at the end of the semester. For each student, identified by an integer number between 1 and 60, four exam grades must be kept, and two final grade averages must be computed. The first grade average is simply the average of all four grades. The second grade average is computed by weighting the four grades as follows: The first grade gets a weight of 0.2, the second grade gets a weight of 0.3, the third grade gets a weight of 0.3, and the forth grade gets a weight of 0.2. That is, the final grade is computed as follows:0.2 * grade1 + 0.3 * grade2 + 0.3 * grade3 + 0.2 * grade4
Using this information, construct a 60-by-7 two-dimensional array, in which the first column is used for the student number, the next four columns for the grades, and last two columns for the computed final grades. The program's output should be display of the data in the completed array. For testing purposes, the professor has provided the following data:
Student Grade 1 Grade 2 Grade 3 Grade 4
1 100 100 100 100
2 100 0 100 0
3 82 94 73 86
4 64 74 84 94
5 94 84 74 64
Explanation / Answer
#include #include using namespace std; int main() { float studentGrade[60][7]; //First zero out the numbers and place the student numbers at the front for(int i = 0; i < 60; ++i) { for(int j = 0; j < 7; ++j) { studentGrade[i][j] = 0; } studentGrade[i][0] = i+1; } //Set some pre-set values studentGrade[0][1] = 100; studentGrade[0][2] = 100; studentGrade[0][3] = 100; studentGrade[0][4] = 100; studentGrade[1][1] = 100; studentGrade[1][2] = 0; studentGrade[1][3] = 100; studentGrade[1][4] = 0; studentGrade[2][1] = 82; studentGrade[2][2] = 94; studentGrade[2][3] = 73; studentGrade[2][4] = 86; studentGrade[3][1] = 64; studentGrade[3][2] = 74; studentGrade[3][3] = 84; studentGrade[3][4] = 94; studentGrade[4][1] = 94; studentGrade[4][2] = 84; studentGrade[4][3] = 74; studentGrade[4][4] = 64; //Get the average of all 4 grades and store in [i][5]; float average; for(int i = 0; i < 60; ++i) { average = 0; for(int j = 1; j < 5; ++j) { average += studentGrade[i][j]; } studentGrade[i][5] = average/4; } //Get the final grade float finalGrade; for(int i = 0; i < 60; ++i) { finalGrade = 0; finalGrade += studentGrade[i][1]*0.2; finalGrade += studentGrade[i][2]*0.3; finalGrade += studentGrade[i][3]*0.3; finalGrade += studentGrade[i][4]*0.2; studentGrade[i][6] = finalGrade; } //output the array for(int i = 0; i < 60; ++i) { for(int j = 0; j < 7; ++j) { coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.