import java.io.*; import java.text.*; // //while loop-a while loop is used when you need to check a condition //before repeating instructions (permission to enter the loop) // //This program also illustrates the use of a boolean to control a loop public class program5 { static final int WIN=5; //constants must be at the class level, not in methods //not even in main() public static void main(String[] args) throws IOException { boolean done=false; int guess; System.out.println("Number Guessing Game!\n"); while(!done)//or: done==false { System.out.println("Enter your guess: "); BufferedReader in =new BufferedReader (new InputStreamReader(System.in)); guess=Integer.parseInt(in.readLine()); if (guess==WIN) done=true; else done=false; } System.out.println("\nYou Win!!!\n"); } }