#include <iostream>
usingnamespace std;
int main()
{
cout<<"This program computes the average of ";
cout<<"a list of (nonnegative) exam scores."<<endl;
double sum;
int numberOfStudents;
double next;
char answer;
do
{
cout<<"Enter all the scores to be averaged."<<endl;
cout<<"Enter a negative number after ";
cout<<"you have entered all the scores."<<endl;
sum = 0;
numberOfStudents = 0;
cin>>next;
while (next >= 0)
{
sum = sum + next;
numberOfStudents++;
cin>>next;
}
if (numberOfStudents > 0)
cout<<"The average is "<<(sum / numberOfStudents)<<endl;
else
cout<<"No scores to average."<<endl;
cout<<"Want to average another exam?"<<endl;
cout<<"Enter y for Yes or n for no."<<endl;
cin>>answer;
}
while (answer=='y'|| answer=='Y');
system ("pause");
return 0;
}