Assignemnt #61
Code
///colin hinton
///5th period
///keep guessing
///KeepGuessing.java
///11/3/2015
import java.util.Scanner;
import java.util.Random;
class KeepGuessing
{
public static void main (String [] args)
{
Scanner keyboard = new Scanner(System.in);
int guess;
System.out.print("I have chosen a number between 1 and 10, guess it. ");
guess = keyboard.nextInt();
Random r = new Random();
int x = (1 + r.nextInt(10));
while (x != guess)
{
System.out.print("Nope try again ");
guess = keyboard.nextInt();
}
System.out.println("Congrats you guessed " + guess + " correctly.");
}
}
Picture of the output