QUOTE(villalandron @ 26 Sep, 2008 - 02:46 PM)

QUOTE(red_4900 @ 25 Sep, 2008 - 11:32 PM)

You are very close to the finish. This is easier explained using just code. Let the code talks
cpp
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(void)
{
srand(time(0));
int theNumber = rand() % 10 + 1;
int guess; //no point in initializing this value
char answer;
int guessCount = 1; //initialize counter to 1. since do-while loops will already count once
//you don't need max or min value
cout << "Welcome to Guess The Number" << endl;
cout << "I have a number between 1 and 1000." << endl;
cout << "Can you guess my number?" << endl;
do
{
answer = NULL; //set the answer to NULL so that the loop will not continue in the second round
guessCount++;
cout << "Please type your guess: " << endl;
cin >> guess;
if (guess > theNumber)
cout << "Too high...try again" << endl;
if (guess < theNumber)
cout << "Too low...try again" << endl;
if (guess == theNumber) //careful not to put semicolon here
{
cout << "Excellent! You guessed the number! Would you like to play again? (y or n)?" << endl;
cin >> answer;
if(answer == 'y')
guessCount = 1;
}
}while((answer == 'y') || (guessCount<=7));
system ("pause"); //I would advise against using system function. but, oh well..never mind
return 0;
}
I already added some comment in my code. But feel free to ask if there's anything you don't understand.
Hope that helps you.

Thanks for your help!
These problems seem so easy, especially after working on them for several hours and after looking at the fixed code, it makes me feel like the answer was right in my face. Thanks for your help. All I have to do is now figure out How to output a message after the seventh try and I'll be done. Thanks!
I think I am not using the right symbol or something but I am trying to have the program to say "Sorry, you failed to guess the correct number...would you like to play again?(Y or N)?". I will put a comment where I tried to have the program do that. Any input or advise will greatly help me. Thank You! Here's the program
cpp
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(void)
{
srand(time(0));
int guess;
char answer;
int guessCount = 1;
cout << "Welcome to Guess The Number" << endl;
cout << "I have a number between 1 and 1000." << endl;
cout << "Can you guess my number?" << endl;
do
{
int theNumber = rand() % 10 + 1;
answer = NULL;
guessCount++;
cout << "Please type your guess: " << endl;
cin >> guess;
if (guess > theNumber)
cout << "Too high...try again" << endl;
if (guess < theNumber)
cout << "Too low...try again" << endl;
if (guess == theNumber)
{
cout << "Excellent! You guessed the number! Would you like to play again? (y or n)?" << endl;
cin >> answer;
if(answer == 'y')
guessCount = 1;
}
if (guessCount == 7)
cout "Sorry, you failed to guess the correct number...vould you like to play again?(Y or N)?" << endl;
// This is the way I thought this would work. Any help will be appreciatted.
}while((answer == 'Y' || answer == 'y') || (guessCount<=7));
system ("pause");
return 0;
}
And here are the erro messages:
1>.\ITS275FinalExamVilla.cpp(8) : warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
1>.\ITS275FinalExamVilla.cpp(37) : error C2143: syntax error : missing ';' before 'string'
1>.\ITS275FinalExamVilla.cpp(37) : error C2563: mismatch in formal parameter list
1>.\ITS275FinalExamVilla.cpp(37) : error C2568: '<<' : unable to resolve function overload
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\ostream(974): could be 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=wchar_t,
1> _Traits=std::char_traits<wchar_t>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\ostream(966): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\ostream(940): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1>Build log was saved at "file://c:\Users\Julio\Documents\Visual Studio 2008\Projects\ITS275FinalExamVilla\ITS275FinalExamVilla\Debug\BuildLog.htm"
1>ITS275FinalExamVilla - 3 error(s), 1 warning(s)
**EDIT**