Assignment #61 Keep Guessing

Code

    /// Name: John Huh
    /// Period: 6
    /// Program Name: Keep Guessing
    /// File Name: KeepGuessing.java
    /// Date Finished: 12/8/2015
    
        import java.util.Random;
        import java.util.Scanner;
    
        public class KeepGuessing
        {
            public static void main( String[] args )
            {
                Random r = new Random();
                Scanner keyboard = new Scanner(System.in);
                int guess, answer;
                
                answer = 1 + r.nextInt(10);
                
                System.out.println();
                System.out.println( "I'm thinking of a number from 1 to 10." );
                System.out.print( "Your guess: " );
                guess = keyboard.nextInt();
                System.out.println();
                
                while ( answer != guess )
                {
                    System.out.println( "That is incorrect.  Guess again." );
                    System.out.print( "Your guess: " );
                    guess = keyboard.nextInt();
                }
                
                System.out.println( "That's right!  You're a good guesser." );
                
                System.out.println();
            }
        }
    

Picture of the output

Assignment 1