KeepGuessingAgain
Code
import java.util.Random;
import java.util.Scanner;
public class KeepGuessingAgain
{
public static void main ( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int num, tries;
tries = 0;
System.out.println( "pick number from 1-10" );
num = keyboard.nextInt();
Random r = new Random();
int choice = 1 + r.nextInt(10);
String response = "";
do
{
System.out.println( " TRY AGAIN guess" + tries );
num = keyboard.nextInt();
tries++;
}
while ( num != choice );
System.out.println( "NICE" );
}
}
KeepGuessingAgain