Assignemnt #68 Again With The Number Guessing

Code

/// Name: JJ Deng
/// Period: 6
/// Program Name: Again With The Number Guessing
/// File Name: NumberLikeAgain.java
/// Date Finished: 1/14/2016
  
    
import java.util.Random;
import java.util.Scanner;
    
public class NumberLikeAgain
{
    public static void main(String[] args)
    {
        Scanner keyboard= new Scanner(System.in);
        Random r = new Random();
        int guess=0, attempts= 0, SecretNumber = 1 + r.nextInt(10);
        
            
        System.out.println( "I have chosen a number between 1 and 10" );
        System.out.print(" Your guess: ");
        guess = keyboard.nextInt();
        attempts++;
        
        do
        {
            
        System.out.println( "That's incorrect. Guess again." );
        System.out.print(" Your guess: ");
        guess = keyboard.nextInt();
        attempts++;
            
        }
        while ( guess!= SecretNumber);
        System.out.println( "That's right! You're a good guesser. It only took you " + attempts + "tries. ");
    }
}
  

Picture of the output

Assignment 73