Write GuessGame. The first input is the secret number (in a real game it would be random); then come the player's guesses. For each guess print 40 is too low or 40 is too high. Stop when the guess is correct, after 7 tries, or when there is no more input:
50 is too high
25 is too low
Correct! Found in 3 tries
or Game over. The number was 37 (write 1 try when found at once). Use a while loop with a boolean flag, and in.hasNextInt().