/* Example 5-6 from the text */ import java.util.Scanner; class HiLo { public static void main(String [] args){ int num,guess,count = 0; boolean done = false; // flag used to control the loop. Scanner console = new Scanner(System.in); num = (int) (Math.random() * 100); while(!done){ ++count; System.out.print("Enter an integer greater than" + " or equal to 0 and less than 100:\t"); guess = console.nextInt(); System.out.println(); if(guess == num){ System.out.println("You got it"); done = true; } else if(guess < num) { System.out.println("Your guess is low"); } else{ System.out.println("Your guess is high"); } }// end while System.out.println("Number of guesses\t" + count); } }