#include #include #include using namespace std; int main() { ifstream inputfile; inputfile.open("grades.txt"); string header; string first; string last; int id; int grade1; int grade2; int grade3; float average; // read the first line because we don't need it // we can't avoid reading it because we have to read // the file from top to bottom getline(inputfile, header); while(inputfile >> first >> last >> grade1 >> grade2 >> grade3) { cout << first << " " << last << "'s average = " << (grade1+grade2+grade3) / 3 << endl; } inputfile.close(); return 0; }