QUOTE(JackOfAllTrades @ 4 Oct, 2008 - 06:52 AM)

Add another check in the inner do/while loop against guessCount?
Just think about it. Write it out on paper as a flow chart. It's not difficult, so don't try to make it more difficult than it needs to be!
I have been trying on my own and can't get it. Here is what I got:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
const int maxNumber = 1000;
int generateNumber()
{
return rand() % maxNumber + 1;
}
bool playAgain()
{
char answer;
cout << "Would you like to play again(Y or N)? ";
cin >> answer;
cin.ignore();
return (answer == 'Y' || answer == 'y');
}
int main(void)
{
srand(time(0));
int guess;
char answer;
int guessCount = 1;
int playCount = 0;
cout << "I have a number between 1 and " << maxNumber << "." << endl;
cout << "Can you guess my number?" << endl;
int theNumber = generateNumber();
do {
guessCount = 0;
playCount++;
cout << "Please type your first guess: ";
cin >> guess;
if (guess > theNumber)
cout << "Too high...try again!" << endl;
else if (guess < theNumber)
cout << "Too low...try again!" << endl;
guessCount++;
} while ((guess > theNumber || guess < theNumber) || (guessCount == 7));
cout << "Excellent! You guessed the number! Would you like to play again? (Y/N) ";
cin >> answer;
if (playAgain())
{
theNumber = rand() % maxNumber + 1;
guessCount = 1;
}
if (playCount == 7)
{
cout << "Sorry, you failed to guess the correct number ("
<< theNumber << ")" << endl;
} while((answer == 'Y' || answer == 'y'));
cin.get();
return EXIT_SUCCESS;
}
Thank You for your help