/*
The following program reads the name of an input file that contains 
floating-point grades separated by space or new lines or tabs and then 
it finds the average grade, the maximum grade, and the minimum grade. 
The grades are assumed to be between 0 and 100.
 */
#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int main()
{
	ifstream inputFile;
	string inputFileName;
	float grade, sum = 0, min = 1000, max = -1;
	int count = 0;
	cout << "Enter the name of the input file: ";
	cin >> inputFileName;
	inputFile.open(inputFileName.c_str());
	if (!inputFile)
	{
		cout << "Can't open the file." << endl;
		return 1;
	}
	inputFile >> grade;
	while (inputFile)
	{
		count++;
		if (grade > max)
			max = grade;
		if (grade < min)
			min = grade;
		sum += grade;
		inputFile >> grade;
	}
	inputFile.close();
	if (count > 0)
	{
		cout << "The average is: " << sum / count 
			<< "." << endl;
		cout << "The heighest grade is: " << max 
			<< "." << endl;
		cout << "The lowest grade is: " << min 
			<< "." << endl;
	}
	return 0;
}
