okay, so I'm a little lost on how to use selection sort and i/o files for this project. the program is supposed to sort a list of first and last names into alphabetical order. here's the catch. each name has a GPA that goes with it. so not only do you sort the name, you also sort the GPA, then after that, you sort from highest to lowest GPA with the corresponding name. you read from a file to get name and GPA info.
example:
data.txt:
Jim Johnson 3.50
Mike Smith 3.99
Cynthia Jones 3.25
Lake Martin 3.75
Olga Gavrylyako 3.00
Jim Brown 4.00
not much luck so far. this is all I've figured out and it doesn't even compile. I was trying to sort the names alphabetically first then I was going to work on the code for GPA.
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main(){
int length=20;
string temp, name[20];
ifstream students.open("data.txt");
while(students>>temp){
for (int a=1; a<length; a++)
temp=name[a];
for (int k=a-1; k>=0 && name[k]>temp; k--){
name[k+1] = name[k];
name[k+1]=temp;
for(int a=0;a<length;a++) cout<<name[a]<<" ";
cout<<endl;
}
students.close();
return 0;
}