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

The purpose of this program is to create a grade report for a course. Write a pr

ID: 3695169 • Letter: T

Question

The purpose of this program is to create a grade report for a course. Write a program that stores the following data about a student in a structure studentRecord - Student's Name: string type (only FirstName) - Student ID: int type - Assignment Scores: array of 4 integers. Each score is from 100 points. - Average: double type There are 3 students in a course. So, you need to create array of structures to hold data of the three students. When the program runs, it should read the data for each student from a file students.txt (see example below for file format). Average needs to be calculated in your program. It should display data in tabular form that lists each student's name, ID, and the 4 assignment scores along with the calculated average of their assignment scores respectively. The program should also calculate and display the Name and ID of the student receiving the highest average. Input File Format: Will 110 65 90 85 84 Taylor 60 90 86 92 89 Johnny 150 62 80 73 75 OUTPUT FORMAT: (example)

Explanation / Answer

Please keep students.txt in same folder( same folder where you put your program) and put data in students.txt in given format and test it.

#include<iostream>
#include<fstream>

using namespace std;

struct Student{
   string name;
   int id;
   double scores[4];
   double average;
};

int main(){
  
   ifstream input;
   input.open("students.txt");
  
   Student students[3];
  
   int i=1;
  
   while(i<=3){
       input>>students[i].name>>students[i].id>>students[i].scores[0]>>
       students[i].scores[1]>>students[i].scores[2]>>students[i].scores[3];
      
       students[i].average = (students[i].scores[0]+students[i].scores[1]+
                               students[i].scores[2]+students[i].scores[3]);
       i++;
   }
  
   int max = i;
   int max_avg = students[i].average;
   cout<<"ID   "<<"Name       "<<"Score1   "<<"Score2   "<<"Score3   "<<"Score4   "<<"Average"<<endl;
   for(int i=0; i<4; i++){
       cout<<students[i].id<<"   "<<students[i].name<<"   "<<students[i].scores[0]<<"   "<<
       students[i].scores[1]<<"   "<<students[i].scores[2]<<"   "<<students[i].scores[3]<<"   "<<students[i].average<<endl;
      
       if(max_avg < students[i].average){
           max_avg = students[i].average;
           max = i;
       }
   }
  
   cout<<" Higest Average is "<<students[max].average<<" scored by ID#"<<students[max].id<<", "<<students[max].name<<endl;
  
   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