Assignemnt #61: While Loops a Guessing Game

Code

 /// Name: Sean Harrison
    /// Period: 7
    /// Program name: Keep Guessing
    /// File Name: KeepGuessing.java
    /// Date Finished: 12/3/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 randomNumber, guess;
    randomNumber = 1 + r.nextInt(10);
    System.out.println( " I have choosen a random number from 1 through 10, you will attempt to guess it until you are correct. " );
    guess = keyboard.nextInt();
    while ( guess != randomNumber )
        {
            System.out.println( " You are incorrect please try again. " );
            guess = keyboard.nextInt();
        }
            System.out.println( " Nice job, you picked the correct number. " );
        }
    }
        
    
 

Picture of the output

Assignment 61