/*
Solution of Assignment 5 for CSIT 121 (Fall 04).
*/
#include <iostream>
using namespace std;
int main()
{
	int count = 0, countFail = 0, countOutstand = 0;
	// count is for the number of valid grades (0 to 100).
	// countFail is for the number of failing grades (0 to 59).
	// countOutstand is for the number of outstanding grades (90 to 100).
	int sentinel = -1111, max = -1, min = 1000;
	// max is for the maximum grade.
	// min is for the minimum grade.
	int grade;
	float avg = 0;
	// avg is for the average of the valid grades.
	// Priming read
	cout << "Enter a grade between 0 and 100, or "
		<< "enter -1111 to stop: ";
	cin >> grade;
	while (grade != sentinel)
	{
		if (grade >= 0 && grade <= 100)
		{
			count++;
			avg += grade;
			if (grade >= 90)
				countOutstand++;
			else if (grade < 60)
				countFail++;
			if (grade > max)
				max = grade;
			if (grade < min)
				min = grade;
		}
		else
			cout << "Invalid Grade: The grade should be "
			<< "between 0 and 100, or -1111 to stop.\n";
		cout << "Enter a grade between 0 and 100, or "
			<< "enter -1111 to stop: ";
		cin >> grade;
	}
	if (count == 0)
		cout << "No valid grades were entered.\n";
	else
	{
		cout << "\tThe average is: " << avg/count << ".\n";
		cout << "\tThe maximum grade is: " << max << ".\n";
		cout << "\tThe minimum grade is: " << min << ".\n";
		cout << "\tThe number of outstanding grades is: " 
			<< countOutstand << ".\n";
		cout << "\tThe number of failing grades is: " 
			<< countFail << ".\n";
	}
	system("pause");
	return 0;
}

