/*
This program keeps reading nonnegative integers 
and it stops when a negative integer is read. 
At that time it prints the average of the 
nonnegative numbers that have been entered.
*/
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int n, sum = 0, count = 0;;
	cout << "Enter a non-neg. int. "
		<< "To stop enter a neg. number: ";
	cin >> n;
	while (n >= 0)
	{
		sum += n;
		count++;
		cout << "Enter a non-neg. int. "
			<< "To stop enter a neg. number: ";
		cin >> n;
	}
	if (count == 0)
		cout << "No nonnegative numbers were entered.\n";
	else
		cout << float(sum)/count << endl;
	return 0;
}

