Assignemnt #72, Again With the Number-Guessing

Code

      /// Name: Alex Pinder
      /// Period: 5
      /// Program Name: Again With the Number-Guessing
      /// File Name: prog72.java
      /// Date Comlete: 1/18/16
            
      import java.util.Random;
      import java.util.Scanner;
            
      public class prog72
      {
          public static void main( String[] args )
          {
              Random r = new Random();
              Scanner keyboard = new Scanner(System.in);
                    
              int answer = 1 + r.nextInt(10);
              int guessNumber = 1;
              int guess;
                    
              System.out.println( "I'm thinking of a number between 1 and 10. Try to guess it!" );
              
              do
              {
                  System.out.print( "Your guess: " );
                  guess = keyboard.nextInt();
                  guessNumber++;
                  if ( guess != answer )
                      System.out.println( "That is incorrect. Guess again." );
              } while ( guess != answer );
              
              System.out.println( "Thats Right! You're a good guesser.\nIt only took you " + guessNumber +" times!" );
          }
      }
    

Picture of the output

Assignment 72