Prog 72: Again with the Number Guessing
///Name: Ilana Levy
///Period: 5
///Program Name: Again with the Number-Guessing
///File Name: numberGuess3.java
///Date Finished: 9/24/2015
import java.util.Scanner;
import java.util.Random;
public class numberGuess3
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner( System.in );
Random r = new Random();
int guess, rand, tries = 0;
System.out.println("I have chosen a number between 1 and 10. Try to guess it." );
rand = 1 + r.nextInt(10);
do
{
System.out.print( "Your guess: " );
guess = keyboard.nextInt();
if (guess !=rand )
System.out.println( "That is incorrect. Guess again." );
tries++;
} while( guess != rand );
System.out.println( "That's right! You're a good guesser.\nIt only took you " + tries + " tries. " );
}
}