Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that a C++ program that can be used to determine grades at the e

ID: 638189 • Letter: W

Question

Write a program that a C++ program that can be used to determine grades at the end of the semester.

For each student, who is identified by an integer number between 1 and 60, four examination grades

must be kept. Additionally, 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 a weight of 0.3, and the fourth grade a weight of 0.2; that is computed as:

0.3*grade1 + 0.2 *grade2 + 0.2 * grade3 + 0.3 * grade4

Using this information, you are to construct a 60 X 7 two dimensional array, in which the first column is

used for the student number, the next four columns for the grades, and the last two columns for the

computed final grades. The output of the program should be a display of the data in the completed

array

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

Your program should print the grade matrix, including the averages. Then it should calculate the mean

and standard deviation for both averages for the class and print the results.

Program Organization

The main() routine should declare and populate the array with the test data shown above. It should then

call a function, passing in the array as a parameter. The function should perform the calculations and print

the result

Explanation / Answer

#include <iostream>
using namespace std;

void calculation(int a[][5]);

int main()
{
   int grades[5][5] = {
                      {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},
                       };

   calculation(grades);
    return 0;
}


void calculation(int a[][5])
{
    int sum = 0;
    double sum1 = 0.0;
    double avg = 0.0;
   double sum2 = 0.0;

   cout << "ID Grade1 Grade2 Grade3 Grade4 Average1 Average2 Mean STD" << endl;
    for (int i = 0; i < 5; i++)
    {
       for (int j = 0; j < 5; j++)
       {
           cout << a[i][j] << "     ";
           if (j != 0)
           {
              sum = sum + a[i][j];
              if ((j == 1) || (j == 4))
               sum1 = sum1 + (0.3 * a[i][j]);
              else
               sum1 = sum1 + (0.2 * a[i][j]);
           }
       }
       avg = (sum / 4.0);
       cout << "   " << avg << "    " << (sum1 / 4.0) << "       " << avg << "     ";
       for (int k = 0; k < 5; k++)
       {
           if (k != 0)
           {
               sum2 = sum2 + pow((a[i][k] - avg), 2);
           }
       }

       cout << sqrt(sum2 / 4.0);
       sum = 0;
       sum1 = 0.0;
       cout << endl;
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote