/* CS102 -- Jim Plank */

/* Here's a simple number-guessing program.  It has the user
   guess a number between 0 and 999 (the answer is 667).  It
   gives the user ten guesses before stopping. 

   It illustrates if statements, while statements, and some compound
   boolean expressions. */

#include <iostream>
using namespace std;

main()
{
  int answer = 667;
  int guess;
  int number;
  int right;

  number = 1;
  right = 0;

  while (number <= 10 && !right) {

    cout << "Guess #" << number << ": Enter a number between 0 and 999: ";
    cin >> guess;
    
    if (guess >= 0 && guess <= 999) {
      if (guess == answer) {
        cout << "Right!";
        cout << "\n";
        right = 1;
      } else {
        cout << "Wrong.\n" ;
      }
    } else {
      cout << "Between 1 and 999, please.\n";
    }
    number++;
  }
   
  return 0;
}

