import java.io.*; public class Guessing { static BufferedReader keyboard = new BufferedReader (new InputStreamReader (System.in)); public static void main (String[] args) throws IOException { int answer, guess; // generate a random integer between 1-10 answer = (int) ((Math.random()*10) + 1); // ask the user for a number System.out.println ("I'm thinking of a number between 1-10"); System.out.print ("What's your guess? "); guess = Integer.parseInt(keyboard.readLine()); boolean correctGuess = false; while (!correctGuess) { // is the user right? if (guess == answer) { System.out.println ("You got it! Good guessing!"); correctGuess = true; } else { System.out.println ("That is not correct"); System.out.print ("Guess again moron: "); guess = Integer.parseInt(keyboard.readLine()); } } } }