#include <iostream>
using namespace std;
// Incorrect averaging program!
// See if you can figure out what's wrong with it.

int main () {
	int count = 0;
	double grade;
	double total = 0.0;
	cout << "Enter first grade (-1 to exit): ";
	cin >> grade;
	total = grade;
	// repeat until a negative grade stops input (sentinel value)
	while (grade >= 0) {
		count = count + 1; // count the grade
		cout << "count is now " << count << endl;
		cout << "running total is " << total << endl;
		cout << "Enter next grade (-1 to exit): ";
		cin >> grade;
		total = total + grade; // add the grade to the total
	}
	cout << "Number of grades = " << count << "\n";
	cout << "Total = " << total << endl;
	cout << "Average = " << total / count << endl;
	return 0;
}

