The data file named studentfile.txt contains the following information
CRYSTAL LEONARD 92
ANN MOORE 88
DAVID JONES 100
JOE CARSON 76
------------------------------------------------------------------
//// Author: Lauren Settle//// Program: Student Test Scores//// This program prompts the user to input the names of students followed by the corresponding test scores.// The program will then read and output the student name, test score, and the letter grade based on the score.// The program will also output the highest test score along with the student who recieved it.////#include <iostream>#include <fstream>#include <iomanip>#include <string>using namespace std;struct studentType{ string studentFName; //students first name string studentLName; //students last name int testScore; //students test score char grade; //corresponding letter grade};void openFile (fstream& inFile);void getData (fstream& inFile, studentType studentData[], int listSize);void assignGrade (studentType studentData[], int listSize);void highScore (studentType studentData[], int listSize); void printResults (studentType studentData[]);int main(){ fstream inFile; studentType studentData[20]; int listSize = 20; openFile (inFile); getData (inFile, studentData, listSize); assignGrade (studentData, listSize); highScore (studentData, listSize); printResults (studentData); /* Scaffolding code for testing purposes */ cin.ignore(256, '\n');cout << "Press ENTER to continue..." << endl;cin.get();/* End Scaffolding */ return 0;}void openFile (fstream& inFile){ inFile.open ("STUDENTFILE.TEXT", ios::in); }void getData (fstream& inFile, studentType studentData[], int listSize){ int j; while (!inFile.eof()) { for (j = 0; j < listSize; j++) { inFile >> studentData[j].studentFName >> studentData[j].studentLName >> studentData[j].testScore; } }}void assignGrade (studentType studentData[], int listSize){ int j; for (j = 0; j < listSize; j++) { if (studentData[j].testScore >= 90) studentData[j].grade = 'A'; else if (studentData[j].testScore >= 80) studentData[j].grade = 'B'; else if (studentData[j].testScore >= 70) studentData[j].grade = 'C'; else if (studentData[j].testScore >= 60) studentData[j].grade = 'D'; else studentData[j].grade = 'F'; }}void highScore (studentType studentData[], int listSize) { int i; double maxScore = 0; int m; for (i = 1; i < listSize; i++) if (studentData.testScore >= maxScore) { maxScore = studentData.testScore; m = i; }}void printResults (studentType studentData[]){ int j, m; cout << left; cout << studentData[j].studentLName << " , "; cout << studentData[j].studentFName; cout << right; cout << setw(15) << studentData[j].testScore; cout << setw(20) << studentData[j].grade; cout << endl << endl << endl << endl; cout << left; cout << " Highest Test Score " << endl; cout << studentData[m].testScore; cout << setw(10) << studentData[m].studentFName << " " << studentData[m].studentLName; cout << endl;}[Edited by - Zahlman on November 20, 2010 2:32:16 AM]