
//*****************************************************************************
////  Course:             COMS 2104 03 Foundations of Computer Programming I
////  Semester:           Spring 2004
////  Assignment Number:  #5                             
////  Author Name:        DarC KonQuesT                        
////  Date Written:       March 4, 2004
////                                                         
////  Description of Program:                              
////  Generates random number and asks user to guess what the number is.
////                               
////*****************************************************************************
#include <iostream>
#include <ctime>  
#include <cstdlib>
using namespace std;
int main()
{
	int seed, guess, count;
	char playchar;
	bool play, valid,correct;
	play = true;
while(play == true)
{

	correct = false;
	valid = false;
	correct = false;

	
	seed = time(NULL);
	srand(seed);
	seed = rand() % 10 + 1; 

	count = 0;
	
	cout << endl << "I am thinking of a whole number between 1 and 10" << endl;
	
	while(correct == false)
	{
	cout << "Guess my number: ";
	cin >> guess;

	if(guess != seed)
	{	
	cout << endl << endl << "Wrong!" << endl << endl;
	++count;
	}
	else
	{	
	++count;
	if(count > 1)
	{
	cout << "That's right!" << endl << "You got my number in " << count << " guesses!!!";
	correct = true;
	}
	else if(count == 1)
	{
	cout << "Wow!  You got my number in one guess!!!" << endl;
	correct = true;
	}
	}
	}
	while(valid == false)
	{
	cout << endl << "Do you want to play one more time? [y/n]: ";
	playchar = ' ';
	cin >> playchar;
	if(playchar == 'y' || playchar == 'Y')
	{
		play = true;
		valid = true;
	}
	else if(playchar == 'n' || playchar == 'N')
	{
		play = false;
		valid = true;
	}
	else
	{
		cout << "Please enter Y or N" << endl;
		valid = false;		
	}
	}
}
}

