Assignment #61
Code
///Name: Cody Swain
///Period: 6
///Project Name: KeepGuessing
///File Name: KeepGuessing.java
///Date: 12/1/15
import java.util.Random;
import java.util.Scanner;
public class KeepGuessing
{
public static void main( String[] args )
{
Random r = new Random();
Scanner keyboard = new Scanner(System.in);
int secretNumber = 1 + r.nextInt(10);
int guess;
System.out.println("I'm thinking of a number between 1-10 ");
System.out.println();
System.out.print("Yout Guess: ");
guess = keyboard.nextInt();
while ( guess != secretNumber ){
System.out.println("Nope, guess again: ");
guess = keyboard.nextInt();
}
System.out.println("That's correct, my secret number was " + secretNumber );
}
}
Picture of the output