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

Create a structure representing a student. The member variables should include s

ID: 3586591 • Letter: C

Question

Create a structure representing a student. The member variables should include student name, student ID, and four test grades for the student (an array of four grades as a member variable). Prompt the user to enter the name, ID, and the four test results. Store all the data in the structure. Calculate the average of the three highest grades, dropping the lowest one. Display the student's name, ID number, four test grades, and the average of the three highest grades. Use a loop to repeat the questions for the next student. Terminate the program when the user decides to stop. Create three separate functions, one to get the information from the user, one to perform calculations, and another one to display the information. Do NOT use any global variables. Pass the object to your functions. In one of the functions, pass by value, one by reference, and one by pointer. This way, you will practice all different ways objects can be passed to functions. You can decide on the functions’ return type. You can also pass the pointer as a constant pointer if necessary. Requirements: 1) Comments are extremely important. Add comments as you code. Do NOT wait until you are done coding. Also, in the beginning of your codes include the following comments: a. Purpose of the program b. Name of the author c. Date 2) Use proper naming conventions for your variables and functions. 3) Tell the user what the program is all about, and the game works. Do NOT start the program with “Enter a number”!! 4) Test, test, and test. + Object Oriented Programming Create a structure representing a student. The member variables should include student name, student ID, and four test grades for the student (an array of four grades as a member variable) Prompt the user to enter the name, ID, and the four test results Store all the data in the structure. Calculate the average of the three highest grades, dropping the lowest one. Display the student's name, ID number, four test grades, and the average of the three highest grades. Use a loop to repeat the questions for the next student. Terminate the program when the user decides to stop Create three separate functions, one to get the information from the user, one to perform calculations, and another one to display the information. Do NOT use any global variables. Pass the object to your functions. In one of the functions, pass by value, one by reference, and one by pointer. This way. you will practice all different ways objects can be passed to functions. You can decide on the functions return type. You can also pass the pointer as a constont pointer if necessory. 1) Comments are extremely important. Add comments as you code. De NOT wait until you are done coding. Also, in the beginning of your codes include the following comments a. Purpose of the program b. Name of the author c Date 2) Use proper naming conventions for your variables and functions. 3) Tell the user what the program is all about, and the game works. Do NOT start the progrom with "Enter a number"! 4) Test, test, and test,

Explanation / Answer

#include<iostream>
#include<string>

using namespace std;

struct Student {
   string name;
   string id;
   int grades[4];
};

void getInfo(Student &s){
  
   
    cout << "Enter name:" ;
    getline(cin,s.name);
    cout << "Enter ID:";
    cin >> s.id;
    cout << "Enter four test gardes :";
    for (int i = 0; i<4; i++)
        cin >> s.grades[i];

}

double getAverage(Student s){

    int temp;
    double sum;
    double avg;
    for (int i = 0; i<4; i++){ // Sorting them in descending order to pick first three highest scores
       for (int j = i; j<4; j++){
          if (s.grades[j] > s.grades[i]){
              temp = s.grades[i];
              s.grades[i] = s.grades[j];
              s.grades[j] = temp;
          }
       }
     }
     sum = 0;
     for (int i = 0; i<3; i++){
         sum = sum + s.grades[i];  
     }
     avg = sum/3;
     return avg;
}

void disp(Student *s){
    cout << s->name << endl;
    cout << s->id << endl;
    for (int i = 0; i<4; i++)
        cout << s->grades[i] << " ";
    cout << endl;
    cout << "Average :" << getAverage(*s) << endl;
   
}


int main(){

   Student st;
   int ch;

   while(true){
       getInfo(st);
       disp(&st);
       cout << "Enter '1' to continue '0' to quit :";
       cin >> ch;
       if (ch == 0)
          break;     
   }
   return 0;
}

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