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

Write a C++ program to calculate the course grade using functions and arrays. Th

ID: 3570743 • Letter: W

Question

Write a C++ program to calculate the course grade using functions and arrays. The following is the weight of each task as part of the total grade: Lab exercises (10 labs): 20% Home work (8 sets):10% Midterm:30% Final Exam:40% There are 10 students in the class. You need to find the lowest score among lab grades for each student and eliminate it and then calculate the course grade for each student. Also you must find the student that got the maximum grade in the class. Declare an array of strings for student names, an array of double for their averages, an array of char for their letter grades and an array of integer for test scores (or you can define 5 different arrays for each student's scores). List of suggested functions that you need to use: void ProgramInfo() void GetStudentInfo(string& name, int score[]) int lowestScore(const int score[]) void StudentMax( const int score[]) void ComputeCourseGrade(int score[], double& average, char& grade) void PrintInfo( const & name, int score[], double& average char& grade) Use functions only in the main function to calculate the students' grades.

Explanation / Answer

Program Code:

// StudentData.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"

#include <iostream>

#include <string>

#include<iomanip>

#include <fstream>

using namespace std;

void ProgramInfo();

void GetStudentInfo(string& name, int score[]);

int lowestScore(const int score[]);

void StudentMax(const double score[]);

void ComputeCourseGrade(int score[], double& average, char& grade);

void PrintInfo(const string& name, int score[], double& average, char& grade);

int getTotal(int score[]);

int getTotalHomeworks(int homeworks[]);

void GetLabHomeMidFinal(int score[],int labscore[], int homeworks[],int &mid, int &final);

int main()

{

     int labscores[10];

     int homeworks[8];

     int mid, final;

     string name[3];

     int score[3][20];

     double average[3];

     char grade[3];

     int lowestscore=0;

     int totalabs;

     int totalhomeworks;

     double labweight;

     double hw;

     double maxGrade;

     int j=0;

     double midterm, finalterm;

     ProgramInfo();

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

     {

          GetStudentInfo(name[i], score[i]);

        

        

          GetLabHomeMidFinal(score[i], labscores, homeworks, mid, final);        

          lowestscore=lowestScore(score[i]);

          totalabs=getTotal(labscores);

          labweight=((totalabs-lowestscore))*20/100.0;

          totalhomeworks=getTotalHomeworks(homeworks);

          hw=((totalhomeworks))*10/100.0;

          midterm=mid*30/100.0;

          finalterm=final*40/100.0;

          average[i]=(labweight+hw+midterm+finalterm)/4;

          ComputeCourseGrade(score[i],average[i],grade[i]);  

        

          cout<<"Lowest score in labs is: "<<lowestscore<<endl;

     }

     cout<<"------------------------------------------------------------------------------";

     cout<<" Name"<<setw(40)<<"Scores"<<setw(40)<<"Average"<<" "<<"Grade"<<endl;

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

     {

          PrintInfo(name[i], score[i], average[i], grade[i]);

          cout<<endl;

     }

     StudentMax(average);

     system("pause");

     return 0;

}

void ProgramInfo()

{

     cout<<"************Students Information**********"<<endl;

     cout<<"Program computes the grades, averages, minimum score in labs, maximum grades. ";

}

void GetStudentInfo(string& name, int score[])

{

     cout<<"Enter name: ";

     cin>>name;

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

     {

          if(i<10)

          {

              cout<<"Enter lab scores";

              cin>>score[i];

          }

          else if(i>=10 && i<18)

          {

              cout<<"Enter homework scores: ";

              cin>>score[i];

          }

          else

          {

              cout<<"Enter exam scores: ";

              cin>>score[i];

          }

     }

}

void GetLabHomeMidFinal(int score[],int labscores[], int homeworks[], int &mid, int &final)

{

     int j=0, k=0;

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

     {

          if(i<10)

          {

              labscores[j]=score[i];

              j++;

            

          }

          else if(i>=10 && i<18)

          {

              homeworks[k]=score[i];

              k++;

            

          }

          else if(i==18)

          {

              mid=score[i];

          }

          else

              final=score[i];

     }

}

int lowestScore(const int score[])

{

     int temp;

     temp=score[0];

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

     {

          if (score[i] < temp)

              temp = score[i];

     }

     return temp;

}

int getTotal(int score[])

{

     int total=0;

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

     {

          total+=score[i];

     }

     return total;

}

int getTotalHomeworks(int homeworks[])

{

     int total=0;

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

     {

          total+=homeworks[i];

     }

     return total;

}

void ComputeCourseGrade(int score[], double& average, char& grade)

{

          if(average<=100&&average>90)

          {

              grade='A';

          }

          else if(average<=90&&average>85)

          {

              grade='A-';

          }

          else if(average<=85&&average>80)

          {

              grade='B+';

          }

          else if(average<=80&&average>75)

          {

              grade='B';

          }

          else if(average<=75&&average>70)

          {

              grade='B-';

          }

          else if(average<=70&&average>65)

          {

              grade='C+';

          }

          else if(average<=65&&average>60)

          {

              grade='C';

          }

          else if(average<=60&&average>55)

          {

              grade='C-';

          }

          else if(average<=55&&average>50)

          {

              grade='D+';

          }

          else if(average<=50&&average>45)

          {

              grade='D';

          }

          else if(average<=45&&average>40)

          {

              grade='D';

          }

          else

          {

              grade='F';

          }

}

void PrintInfo(const string& name, int score[], double& average, char& grade)

{

     cout<<name<<setw(10);

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

              cout<<score[i]<<" ";

          cout<<average<<setw(10)<<grade<<endl;

}

void StudentMax(const double score[])

{

     int temp;

     temp=score[0];

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

     {

          if (score[i] > temp)

              temp = score[i];

     }

     cout<<"The highest grade obtained is: "<<temp<<endl;;

}

Sample output:

************Students Information**********

Program computes the grades, averages, minimum score in labs, maximum grades.

Enter name: Alex

Enter lab scores60

Enter lab scores60

Enter lab scores

45

Enter lab scores90

Enter lab scores80

Enter lab scores85

Enter lab scores82

Enter lab scores75

Enter lab scores65

Enter lab scores60

Enter homework scores: 45

Enter homework scores: 50

Enter homework scores: 55

Enter homework scores: 66

Enter homework scores: 65

Enter homework scores: 63

Enter homework scores: 60

Enter homework scores: 62

Enter exam scores: 80

Enter exam scores: 85

Lowest score in labs is: 45

Enter name: Leo

Enter lab scores90

Enter lab scores98

Enter lab scores93

Enter lab scores95

Enter lab scores90

Enter lab scores97

Enter lab scores94

Enter lab scores96

Enter lab scores99

Enter lab scores98

Enter homework scores: 93

Enter homework scores: 94

Enter homework scores: 98

Enter homework scores: 97

Enter homework scores: 96

Enter homework scores: 95

Enter homework scores: 90

Enter homework scores: 89

Enter exam scores: 88

Enter exam scores: 100

Lowest score in labs is: 90

Enter name: Perry

Enter lab scores64

Enter lab scores98

Enter lab scores98

Enter lab scores65

Enter lab scores36

Enter lab scores78

Enter lab scores46

Enter lab scores89

Enter lab scores75

Enter lab scores76

Enter homework scores: 78

Enter homework scores: 72

Enter homework scores: 42

Enter homework scores: 73

Enter homework scores: 66

Enter homework scores: 65

Enter homework scores: 68

Enter homework scores: 50

Enter exam scores: 95

Enter exam scores: 95

Lowest score in labs is: 36

Name                                                                                         Scores                                                                                             Average   Grade

Alex        60 60      45      90      80      85      82      75      65 60      45      50      55      66      65      63      60       62      80      85      58.96       C

Leo        90   98      93      95      90      97      94      96      99      98      93      94      98      97      96      95     90      89      88        100     78.36      B

Perry        64 98      98     65      36      78      46      89      75      76      78      72      42      73      66      65      68      50      95      95     63.885        C

The highest grade obtained is: 78.36

Press any key to continue . . .

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