Guessing numbers
 No. 82
               
| Q: | Write a simple game asking a user to guess a randomly chosen number. Your program will select an integer (pseudo) random number between zero and an exclusive configurable fixed upper limit e.g. 10. The user will have a configurable number of tries to guess the number in question. Each time after entering a number your program will respond with either of the following: 
 The system offers a maximum number of tries e.g. 6. In the following example the system initially selected the secret number 5. A possible dialogue looks like: Try to guess my secret number between 0 and 10: You have 5 attempts Input your guess:4 Value is too low Input your guess:6 Value is too high Input your guess:5 Congratulations, you won! Regarding reading user input and creating random numbers please use the following recipe to get started: package ...
import java.util.Random;
...
   public static void main(String[] args) {
       // Add some parameter here e.g. range of number to be guessed,
       // and number of tries.
      final int randomValue =          // Selecting a pseudo random value
            new Random().nextInt(11);  // between 0 and 10 (inclusive).
      // ToDo: complete the implementation
   } | 
| A: | In case you don't like  ... boolean numberWasFound = false; for (int i = 0; !numberWasFound && i < numOfUserAttempts; i++) { ... } else { numberWasFound = true; // No »break« statement required anymore } } ... | 
