Assignment #61 and Fifty-Eight Program

Code

        /// Name: Georgi Atanasov
        /// Period: 5
        /// Program Name: Keep Guessing
        /// File Name: KeepGuessing.java
        /// Date Finished: 1/5/2016
    
    import java.util.Scanner;
    import java.util.Random;
    
    public class KeepGuessing
    {
        public static void main(String[] args)
        {
            Scanner keyboard = new Scanner(System.in);
            Random r = new Random();
    
            int secretNumber = 1 + r.nextInt(10);
            int guess;
    
            System.out.println("I'm thinking of a number from 1 to 10. Try to guess it.");
    
            System.out.print("Your guess: ");
            guess = keyboard.nextInt();
    
            while (guess != secretNumber)
            {
                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.");
        }
    }
    

Picture of the output

Assignment 61