Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 23rd International Conference Dexa 2012 Vienna Austria September 2012 Proceedings Part 1 Lncs 7446

Authors: Stephen W. Liddle ,Klaus-Dieter Schewe ,A Min Tjoa ,Xiaofang Zhou

2012th Edition

3642325998, 978-3642325991

More Books

Students also viewed these Databases questions

Question

What questions should Jessica ask of Anna?

Answered: 1 week ago