// FILE: SumScore.cpp // ACCUMULATES THE SUM OF EXAM SCORES #include int main () { // Local data ... const int sentinel = -1; // sentinel value int count; // count of scores processed int score; // each exam score int sum; // sum of scores double average; // average of scores processed count = 0; sum = 0; cout << "Enter scores one at a time as requested." << endl; cout << "When done, enter " << sentinel << " to stop." << endl; cout << "Enter the first score: "; cin >> score; while (score != sentinel) { count++; sum += score; cout << "Enter the next score : "; cin >> score; } // end while cout << endl << endl; cout << "Sum of exam scores is " << sum << endl; cout << count << " exam scores were processed." << endl; cout.setf (ios::fixed); cout.precision (1); average = double (sum) / double (count); cout << "Average of the exam scores is " << average << endl; return 0; }