Prog 61: Keep Guessing
///Name: Ilana Levy
///Period: 5
///Program Name: Keep Guessing
///File Name: keepGuessing.java
///Date Finished: 9/21/2015
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 guess, rand = 1 + r.nextInt(10);
System.out.println( "I have chosen a number between 1 and 10. Try to guess it. \nYour guess: " );
guess = keyboard.nextInt();
while ( guess != rand )
{
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." );
}
}