Assignment 61 and Guess
Code
///Matthew Hughs
///Period 5
///Guess
///Guess.java
///12/16/2015
import java.util.Scanner;
import java.util.Random;
class Guess
{
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. ");
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