//************************************************************* // File: highestAvg.cpp /* Description: - Given a list of midn names/alpha codes followed by a comma-separated list of grades followed by a ; - Print out the name of the student with the highest average (and the average). - Input format is demonstrated in this example: John Jeffery Jones m090101 85, 95, 22, 54; Sandra Smith m090201 99, 98; Xavier Xenon Jr m090400 78, 80, 82, 84, 86, 88, 90; - For this input, program would output Sandra Smith had the highest average, a 98.5 */ //********************************************************************* // v1 -- simplified input (one word name, one grade) // Jones m040101 85 // Smith m040201 99 // Xenon m050400 78 #include #include #include using namespace std; int main1232132() { // Open the file ifstream fin("grades1-input.txt"); double maxGrade = -1; string maxGradeName = "nobody"; string name, alpha; double grade; char junkCh; // Process each line while (fin >> name ) { fin >> alpha; fin >> grade; fin >> junkCh; // get semicolon if (grade > maxGrade ) { maxGrade = grade; maxGradeName = name; } } // Output highest average cout << maxGradeName << " had the highest average, an " << maxGrade << endl; return 0; }