import java.util.*; public class GuessMyNumber { public static void main(String[] args) { System.out.println ("This program allows you to guess what " + "number I am thinking of"); final int MAX_NUMBER = 10; Random rand = new Random(); int theNumber = rand.nextInt(MAX_NUMBER); Scanner stdin = new Scanner(System.in); System.out.println ("The number is between 0 and " + (MAX_NUMBER-1)); int count = 0; int guessedNumber = -1; do { System.out.print ("Enter your guess: "); guessedNumber = stdin.nextInt(); count++; } while ( guessedNumber != theNumber); System.out.println ("Correct! You guessed in in " + count + " tries"); } }