//Written by mark lair
//Sept 17, 2007
//Chapter 5
//Assignment 13, The greatest and the least of these 

//this program will calculate the highest and lowest of a 
//list of numbers entered by the user

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{

//define variables

	double smallnum = 0.00;
	double largenum = 0.00;
	double inputnum = 0.00;
	int count = 0;


//get users list of numbers

	while (inputnum != -99)
	{
		if (count == 0)
		{
			cout << "Enter the first in a series of numbers.\n";
			cout << "Enter -99 when finished\n";
			cin >> inputnum;
			smallnum = inputnum;
			largenum = inputnum;
			cout << "This number is the smallest and the largest so far...\n";
			count++;
		}
		else
		{
			cout << "Enter the next in a series of numbers.\n";
			cout << "Enter -99 when finished\n";
			cin >> inputnum;
			if (inputnum < smallnum && inputnum != -99)
			{
				smallnum = inputnum;
				cout << "This is the smallest number so far...\n";
			}

			else if (inputnum > largenum)
			{
				largenum = inputnum;
				cout << "This is the largest number so far...\n";
			}

			count++;
		}
	}

	cout << "You entered " << count << " numbers.\n";
	cout << "The largest was " << largenum << ".\n";
	cout << "The smallest was " << smallnum << ".\n";
		





	system("pause");
	return 0;
}

