Assignemnt #72 and Again with the Number-Guessing

Code

/// Name: Kyle Ivy
/// Period: 5
/// Program Name: NumberGuessAgain
/// File Name: NumberGuessAgain.java
/// Date Finished: 1/5/2016

import java.util.Random;
import java.util.Scanner;
        
    public class NumberGuessAgain {
    
        public static void main( String[] args ) {
        
        Random r = new Random();
        Scanner keyboard = new Scanner(System.in);
        int secretNumber = 1 + r.nextInt(10);
        int guess, tries = 0;
        
        System.out.println("I'm thinking of a number between 1-10. Try to guess it. ");
        System.out.println();
        
        do
        {
            System.out.print("Your guess: ");
            guess = keyboard.nextInt();
            if ( guess != secretNumber ) {
            System.out.println( "That is incorrect. Guess again. " );
            }
            tries++;
        } while ( guess != secretNumber );
            
        System.out.println("That's right! You're a good guesser." );
        System.out.println("It only took you " + tries + " tries. " );
        }
    }
    

prog72.PNG

Assignment 1