Assignment 61
import java.util.Scanner;
import java.util.Random;
public class BetterGuessingGame
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
Random r = new Random();
int answer, guess;
answer = 1 + r.nextInt(10);
guess = 0;
System.out.print("I'm thinking of a number from 1 to 10.\nYour guess: ");
guess = keyboard.nextInt();
while (guess != answer)
{
System.out.print("That is incorrect. Guess again.\nYour guess: ");
guess = keyboard.nextInt();
}
System.out.println("That's right! My secret number was " +guess+ "!");
}
}