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

Respuesta :

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

#include <bits/stdc++.h>

using namespace std;

void func() //Defining function

{

   int m;

  double stu[60][10];

  cout<<"Enter number of students\n"; //taking input

  cin>>m;

  for(int i=0;i<m;i++)

  {

      cout<<"Enter Student Number: ";

      cin>>stu[i][0];

      cout<<"Enter the four grades of student "<<stu[i][0]<<endl;

      cin>>stu[i][1];

      cin>>stu[i][2];

      cin>>stu[i][3];

      cin>>stu[i][4];

  }

 

  //Calculating first grade average and second grade average

  for(int i=0;i<m;i++)

  {

      stu[i][5] = (stu[i][1] + stu[i][2] + stu[i][3] + stu[i][4])/4;

      stu[i][6] = (0.3*stu[i][1] + 0.2*stu[i][2] + 0.2*stu[i][3] + 0.3*stu[i][4]);

  }

  double sumFAvg=0,sumSAvg=0;

  double classFAvg,classSAvg;

  //Calculating average of first and second grades

  for(int i=0;i<m;i++)

  {

      sumFAvg = sumFAvg + stu[i][5];

      sumSAvg = sumSAvg + stu[i][6];          

  }

  classFAvg = sumFAvg/m;

  classSAvg = sumSAvg/m;

   cout<<"-----------Class Info ------------------\n";

  cout<<"StudentID   Grade1 Grade2 Grad3 Grad4 FirstGrade SecondGrade\n";

  for(int i=0;i<m;i++)

  {

      cout<<stu[i][0]<<"\t\t"<<stu[i][1]<<"\t"<<stu[i][2]<<"\t"<<stu[i][3]<<"\t"<<stu[i][4]

      <<"\t"<<stu[i][5]<<"\t"<<stu[i][6]<<endl;

  }

   cout<<"Class First Grade Average: "<<classFAvg<<endl;   //printing output

  cout<<"Class Second Grade Average: "<<classSAvg<<endl;  

 

}

int main() //driver function

{  double sumFAvg=0,sumSAvg=0;

  double classFAvg,classSAvg;

   int m;

  double stu[60][10];

   func(); //calling function

  return 0;

}

Output

Enter number of students 3

Enter Student Number:1 Enter the four grades of student 1-  50 60 70 80

Enter Student Number:2 Enter the four grades of student 2 -30 4 50 6

Enter Student Number:3 Enter the four grades of student 3 - 10 2 30 40

-----------Class Info ------------------

StudentID   Grade1 Grade2 Grad3 Grad4 FirstGrade SecondGrade

1  50 60 70 80 65 65

2  30 4 50 6 22.5 21.6

3  10 2 30 40 20.5 21.4

Class First Grade Average: 36

Class Second Grade Average: 36

Answer:

First grade average: 36

Second grade average: 36

Explanation: