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

Write a c++ program that contains the following functions (For this question, yo

ID: 3721145 • Letter: W

Question

Write a c++ program that contains the following functions (For this question, you can come up with the list of names and test scores, you can reuse some of the names from the project file. Test with at least 10 students
A function that reads in the students' names along with their 5 testscores from a file and into a structure. The struct should have a component for the student's first and last name, testscores, average and grade.
A function that takes in a single student, and calculates their average testscore and fills it in the appropriate position in the struct
A function that uses the above function to fill up the average of every student.
A function that takes in a single student, and determines their grade and puts it in the appropriate location in the struct.
A function that uses the above function to fill up the grade of every student.
A function that takes in all the students and returns the last name of the student with the highest average
A function that takes in all the students and outputs their first and last name along with their highest testscore
A function that takes in all the students and returns the number of students that get a C and above.
A function to print the complete details of a student in the following manner
Name: Kyle Trager
Test 1: 99
Test 2: 99
Test 3: 100
Test 4: 99
Test 5: 99
Highest testscore: 100 in Test 3
Average: 99.2
Grade: A
Everything up to concept of structs is allowed.
Write a c++ program that contains the following functions (For this question, you can come up with the list of names and test scores, you can reuse some of the names from the project file. Test with at least 10 students
A function that reads in the students' names along with their 5 testscores from a file and into a structure. The struct should have a component for the student's first and last name, testscores, average and grade.
A function that takes in a single student, and calculates their average testscore and fills it in the appropriate position in the struct
A function that uses the above function to fill up the average of every student.
A function that takes in a single student, and determines their grade and puts it in the appropriate location in the struct.
A function that uses the above function to fill up the grade of every student.
A function that takes in all the students and returns the last name of the student with the highest average
A function that takes in all the students and outputs their first and last name along with their highest testscore
A function that takes in all the students and returns the number of students that get a C and above.
A function to print the complete details of a student in the following manner
Name: Kyle Trager
Test 1: 99
Test 2: 99
Test 3: 100
Test 4: 99
Test 5: 99
Highest testscore: 100 in Test 3
Average: 99.2
Grade: A
Everything up to concept of structs is allowed.
Write a c++ program that contains the following functions (For this question, you can come up with the list of names and test scores, you can reuse some of the names from the project file. Test with at least 10 students
A function that reads in the students' names along with their 5 testscores from a file and into a structure. The struct should have a component for the student's first and last name, testscores, average and grade.
A function that takes in a single student, and calculates their average testscore and fills it in the appropriate position in the struct
A function that uses the above function to fill up the average of every student.
A function that takes in a single student, and determines their grade and puts it in the appropriate location in the struct.
A function that uses the above function to fill up the grade of every student.
A function that takes in all the students and returns the last name of the student with the highest average
A function that takes in all the students and outputs their first and last name along with their highest testscore
A function that takes in all the students and returns the number of students that get a C and above.
A function to print the complete details of a student in the following manner
Name: Kyle Trager
Test 1: 99
Test 2: 99
Test 3: 100
Test 4: 99
Test 5: 99
Highest testscore: 100 in Test 3
Average: 99.2
Grade: A
Everything up to concept of structs is allowed.

Explanation / Answer

#include<iostream>
#include<string>
#include<fstream>

using namespace std;

struct student{
   string first;
   string last;
   int score[5];
   double avg;
   string grade;
};

int readFile(student *data){
    string name;
    string f,l;
    cout << "Enter file name:"; // file format each line firstname lastname score1,.....score5
    cin >> name;
    int count = 0;
    ifstream fin(name.c_str());
    while (fin >> f >> l){
       data[count].first = f;
       data[count].last = l;
       for (int i = 0; i<5; i++){
           fin >> data[count].score[i];
       }
       count++;
    }
    fin.close();
    return count;
}


void average(student *data){
   double sum = 0;
   for (int i = 0; i<5; i++){
       sum = sum + data->score[i];
   }
   data->avg = sum/5.0;
}


void averageAll(student *data, int n){
   double sum = 0;
   for (int i = 0; i<n; i++){
       average(&data[i]);
   }
  
}


void grade(student *data){
     average(data);
     if (data->avg >= 90)
         data->grade= "A";
     else if (data->avg >= 80)
         data->grade= "B";
     else if (data->avg >= 70)
         data->grade= "C";
     else if (data->avg >= 60)
         data->grade= "D";
     else
         data->grade= "F";
}


void gradeAll(student *data, int n){
   double sum = 0;
   for (int i = 0; i<n; i++){
       grade(&data[i]);
   }
  
}

string highestAvg(student *data, int n){
   double sum = 0;
   int max = data[0].avg;
   string last = "";

   for (int i = 0; i<n; i++){
       if (data[i].avg > max){
          max = data[i].avg;
          last = data[i].last;       
       }
   }
   return last;  
}


void highestScore(student *data, int n){

   for (int i = 0; i<n; i++){
       cout << data[i].first << " " << data[i].last;
       int max = data[i].score[0];      
       for (int j = 0; j<5; j++){
          if (data[i].score[j] > max)
             max = data[i].score[j];
       }
       cout << " Highest Score:" << max << endl;
   }
     
}


int countCgrade(student *data, int n){
   int num =0;
   for (int i = 0; i<n; i++){
       if (data[i].avg >= 60)
           num++;
   }
   return num;  
}


int display(student *data, int n){
   for (int i = 0; i<n; i++){
       cout << "Name:" << data[i].first << " " << data[i].last << endl;
       int max = data[i].score[0];
       int index = 0;
       for (int j = 0; j<n; j++){
          cout << "Test " << j+1 << ": " << data[i].score[j] << endl;
          if (max < data[i].score[j]){
               max = data[i].score[j];
               index = j;
          }
                
       }
      
       cout << "Highest testcore: " << max << " in Test " << index+1 << endl;
       cout << "Average: " << data[i].avg << endl;
       cout << "Grade: " << data[i].grade << endl;
       cout << "-------------------------------------------- ";
      
   }
     
}


int main(){
  
   student data[1000];
   int n = readFile(data);
   averageAll(data,n);
   display(data,n);
           
   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