#include #include #include using namespace std; //We are creating a new // "super" type of variable //made up of many other types //of variables class student { public: string fname; string lname; int id; double exam1; double exam2; double exam3; double average; }; int main() { //step 0: open the input file ifstream infile("studentGrades.txt"); //step 1: read in the number of students, numStudents int numStudents; infile >> numStudents; //step 2: create an array of students //student A[numStudents]; //can't use static array declartion student* studentArray = new student[numStudents]; //dynamic array allocation //step 3: read in the students from the file into the array, calculate average for (int i = 0; i < numStudents; i++) { studentArray[i] = readOneStudentFromFile(infile); studentArray[i].average = computeAverage(studentArray[i]); } //step 4: sort stucents by average selectionSort(studentArray, 0, numStudents - 1); //step 5: output students to output file. ofstream outfile("sortedGradeReport.txt"); for (int i = 0; i < numStudents; i++) { writeOneStudentToFile(studentArray[i], outfile); } return 0; }