Question
Modify the following code to the following : (1) Print EACH Student's Highest and Lowest Grade and the Associated Test Number For example, GIVEN the
Modify the following code to the following :
(1) Print EACH Student's Highest and Lowest Grade and the Associated Test Number
For example, GIVEN the Student's Grades are placed in order of the Tests, that is, the results for Test 1 first, Test 2 second, etc.
Then for these GRADES: 87 78 99 100 34 56 78 89 77 93
Your search would evaluate:
Student's Highest Grade was 100 received on Test 4 and Student's Lowest Grade was 34 received on Test 5.
(2) Modularize the code functionality of the Program
(3) If the Student's Average was not also printed in the Original, Print it now
(4) All Other Output from Lab #1 will remain the Same.
This code will print the grades of 10 students grades and each student has 10 grades. I want to modify it to do the previous questions from 1 to 4 in C++ please and the input should be from a file
//The code starts here
#include
#include
#include
using namespace std;
struct SG{
//Defining Variables
float arraySG[10];
string name;
char LG;
};
//Main starts here
int main(){
SG stud[10];
ifstream in;
//Openning a text file that has all the grades
in.open("/Users/yazanalmatar/Desktop/Student Grades/Student Grades/Text1.txt");
//Throwing a message in case of error
if(in.fail()){
cout<<"Unable to open file"< return 0; } int n=0; while(!in.eof()){ in>>stud[n].name; int sum = 0; for(int i=0; i<10; i++){ in>>stud[n].arraySG[i]; sum += stud[n].arraySG[i]; } double avg = sum / 10; //Avg is the average grade of the students if(avg>=90) stud[n].LG = 'A'; else if(avg>=80) stud[n].LG = 'B'; else if(avg>=70) stud[n].LG = 'C'; else if(avg>=60) stud[n].LG = 'D'; else stud[n].LG = 'F'; n++; } in.close(); for(int i=0; i cout< for(int j=0;j<10; j++){ cout< } cout< } return 0; } //End of the Main
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started