// Example for cs 149 // Illustrates opening and using files // Illustrates use eof. #include // New!!! #include //#include // for rand() using namespace std; int main() { char ans='y'; int i, n, sum; fstream list; // New! // Now open the list just created and add up what's there. int temp, ct=0, tempSum=0, Max=0; list.open("george.txt", ios::in); // New! while ( list >> temp ) { tempSum += temp; ct++; if (temp > Max) Max = temp; } cout<< "Average: " << (float) tempSum/ct << endl; cout << "Max: " << Max << endl; return 0; }