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