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

Using C++ The purpose of this program is to create a grade report for a course.

ID: 3694526 • Letter: U

Question

Using C++

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)

ID NAME Score1 Score2 Score3 Score4 Average
110 Will 65 90 85 84 81.00
60 Taylor 90 86 92 89 89.25
150 Johnny 62 80 73 75 72.50

Highest Average is 89.25 scored by ID#60, Taylor

Explanation / Answer

#include<iostream>
#include<string>
#include<fstream>
#include<iomanip>
using namespace std;
struct student{
string name;
int id;
int scores[4];
double avg;
};

int main(){
struct student s[3];
ifstream file("students.txt");
double max = 0;
int max_index = 0;
for(int i =0;i<3;i++){
int total=0;
file>>s[i].name;
file>>s[i].id;
for(int j =0;j<4;j++){
file>>s[i].scores[j];
total += s[i].scores[j];
}
s[i].avg = total / 4.0;
if(max < s[i].avg){
max = s[i].avg;
max_index = i;
}
}
cout.width(3);
cout<<"ID"<<" ";
cout.width(10);
cout<<"NAME"<<" "<<"Score1 "<<"Score2 "<<"Score3 "<<"Score4 "<<"Average ";
for(int i=0;i<3;i++){
cout.width(3);
cout<<s[i].id<<" ";
cout.width(10);
cout<<s[i].name<<" ";
for(int j =0;j<4;j++){
cout.width(3);
cout<<fixed<<setprecision(3)<<s[i].scores[j]<<" ";
}
cout.width(5);

cout<<fixed<<setprecision(2)<<s[i].avg<<endl;
}
cout<<"Highest Average is "<<max<<" scored by ID#"<<s[max_index].id<<", "<<s[max_index].name;

}

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