Assignemnt #61 and Keep Guessing
Code
///Name: Dakota Donahue
///Period: 5
///Project Name: Keep Guessing
///File Name: KeepGuessing.java
///Date: 1/12/2016
import java.util.Scanner;
import java.util.Random;
public class KeepGuessing
{
public static void main ( String[] args )
{
Scanner keyboard = new Scanner(System.in);
Random r = new Random();
int rN = 1 + r.nextInt(10);
int guess;
System.out.println( " I'm thinking of a number from 1 to 10 " );
System.out.print( " Your guess: " );
guess = keyboard.nextInt();
while ( guess != rN )
{
rN = 1 + r.nextInt(10);
System.out.println( " I'm thinking of a number from 1 to 10 " );
System.out.print( " Your guess: " );
guess = keyboard.nextInt();
}
if ( guess == rN )
{
System.out.println( " That's right! my secret number was " + rN );
}
}
}