Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# include # include # include using namespace std ; class Student{ public: Student(){} friend ifstream& operator >>(ifstream &input, Student& student); friend ostream& operator <

#include

#include

#include

using namespace std;

class Student{

public:

Student(){}

friend ifstream& operator >>(ifstream &input, Student& student);

friend ostream& operator <<(ostream &output, const Student& student);

public:

string name;

string level;

double Gpa;

};

ifstream& operator>>(ifstream &input, Student& student){

input>> student.name>> student.level>> student.Gpa;

return input;

}

ostream& operator <<(ostream &output, const Student& student){

output << student.name<< " ";

output << student.level<< " ";

output<< student.Gpa<< " ";

return output;

}

int main() {

//reading txt file

int i;

Student a;

Student myArray[25];

ifstream myfile("College.txt");

i=0;

string line;

getline(myfile,line);

if (myfile.is_open()) {

while(myfile>>a){

myArray[i]=a;

i++;

}

for (i=0;i<25;i++){

cout<

}

myfile.close(); }

else { cout<<"file is not open"<<' ';

}

//gpa

double sum=0;

for (int i=0;i<25;i++){

sum=sum+ myArray[i].Gpa;

}

double avg=sum/25;

cout<< "class avg: " <

//sort accending

Student temp;

int length=25;

int j;

for(i=0;i<25;i++)

{

for (j=i+1;j<25;j++){

if (myArray[i].name>myArray[j].name)

{

temp=myArray[i];

myArray[i]=myArray[j];

myArray[j]=temp;

}

}} for (i=0;i<25;i++){

cout<

}

this is my current code and i need it to output the text file in accending alphabetical order and state their avg gpa of the entire class. then break it into lists of freshman,sophomore,junior, and senior and state each of the lists avg gpa in alphabetical order. my output is the text file in a weird list form with weird gpa. operator overload and c++ please answer based on my code provided and details provided. thank you

(text file )

NAME STANDING GPA

Williams,Leonard Freshman 1.85

Smith,Sheila Senior 2.99

Anderson,Andy Sophomore 3.01

Wiser,Bud Freshman 4.00

Robertson,Jully Junior 2.78

Koran,Korn Junior 3.50

Smith,Sam Junior 2.14

Johnson,Jim Junior 3.05

Johnson,Jane Junior 3.75

Potter,Pam Senior 2.98

Brown,Bill Sophomore 2.55

Crooks,Cathy Freshman 1.99

Gregg,Howard Senior 2.44

Nicholas,Judy Senior 3.69

White,Bob Sophomore 1.64

Walsh,Fred Junior 4.00

Dennis,Susan Junior 2.06

Roberts,Rachel Sophomore 4.00

Fredericks,Mary Freshman 2.89

Holmes,Wendy Senior 2.56

Green,Barbara Sophomore 3.67

Brown,David Freshman 2.00

Williamson,Walt Sophomore 2.95

Carson,Jim Sophomore 2.03

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago