Question: please answer quickly this is my code and its supposed to read the text file and save it into class of array and then output
please answer quickly this is my code and its supposed to read the text file and save it into class of array and then output it the entire class into accending order and avg gpa of all students and then break it into groups based on their class standing and their avg gpa. my code is outputting blank. so what is the problem what do i need to fix. please answer based on my code and questions and not post another code or answer. c++ operator overload in other post i was provided no answer thats wasting my points and i was unable to comment issue please provide and check answer correctly also my file isnt being saved into the array why not
#include
#include
#include
using namespace std;
class Student{
public:
Student(){}
friend istream& operator >>(istream &input, Student& student);
friend ostream& operator <<(ostream &output, const Student& student);
public:
string name;
string level;
double Gpa;
};
istream& operator>>(istream &input, Student& student){
input>> student.name>> student.level>> student.Gpa;
return input;
}
ostream& operator <<(ostream &output, const Student& student){
output << student.name<< " "<< student.level<< " "<< student.Gpa<< " ";
return output;
}
int main() {
//reading txt file
int i;
Student a;
Student student[25];
ifstream myfile("College.txt");
if (myfile.is_open()) {
while(myfile>>student[i]){
student[i]=a;
i++;
for(int 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+ student[i].Gpa;
cout<
//sort accending
Student temp;
int length=25;
int j;
for(i=0;i<25;i++)
{
for (j=i+1;j<25;j++){
if (student[i].name>student[j].name)
{
temp=student[i];
student[i]=student[j];
student[j]=temp;
}
}}}}
(this is the 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
Get step-by-step solutions from verified subject matter experts
