Assignemnt #55
Code
/// Name: Holden Ganch
/// Period: 7
/// Program Name: fifty fifth Program
/// File Name: Guess.java
/// Date Finished: 11/11/2015
import java.util.Random;
import java.util.Scanner;
public class Guess
{
public static void main ( String[] args )
{
Random r = new Random();
Scanner keyboard = new Scanner(System.in);
int y, x = 1 + r.nextInt(10);
String response = "";
System.out.println("Pick a number from 1-10 ");
System.out.print("> ");
y = keyboard.nextInt();
if ( x == y )
{
System.out.println("You got it right congrats! it was " + x);
}
if ( x != y )
{
System.out.println("You got it wrong what a shame, it was actually it was " + x);
}
}
}
Picture of the output