Code
/// Name: Afaf Nabeeha
/// Period: 7
/// Program Name: Keep Guessing
/// File Name: Guessing.java
/// Date Finished: 12/7/2015 public class Guessing
import java.util.Random;
import java.util.Scanner;
public class Guessing
{
public static void main( String[] args )
{
Random R = new Random();
Scanner keyboard = new Scanner(System.in);
int rNumber, user;
rNumber = 1 + r.nextInt(10);
System.out.println("I have chosen a number between 1 and 10. Try to guess it. ");
System.out.print("Your Guess: ");
user = keyboard.nextInt();
while ( user != rNumber )
{
System.out.println("That is incorrect. Guess again. ");
System.out.print("Your Guess: ");
user = keyboard.nextInt();
}
System.out.println("That's right! You're a good guesser. ");
}
}
Picture of the output