Assignemnt #62
Code
/// Name: Connor Siri
/// Period: 7
/// Program Name: Keep
/// File Name: Keep.java
/// Date Finished: 11/02/2015
import java.util.Random;
import java.util.Scanner;
public class Keep
{
public static void main( String[] args )
{
Random r = new Random();
Scanner keyboard = new Scanner(System.in);
int y = 1 + r.nextInt(10);
System.out.println("Pick a number between 1 and 10");
System.out.print("Your guess: ");
int entry = keyboard.nextInt();
while ( entry != y )
{
System.out.println("\nThat is wrong. Try again");
System.out.print("Your guess: ");
entry = keyboard.nextInt();
}
System.out.println("\nThat is Correct");
}
}
Picture of the output