Assignment 58 and Oneshot
Code
///Matthew Hughs
///Period 5
///Oneshot
///Oneshot.java
///12/9/2015
import java.util.Scanner;
import java.util.Random;
class Oneshot
{
public static void main (String [] args)
{
Scanner keyboard = new Scanner(System.in);
int guess;
System.out.println("I'm thinking of a number between 1-100, guess");
guess = keyboard.nextInt();
Random r = new Random();
int x = (1 + r.nextInt(100));
if ( guess == x)
{
System.out.println(" You got it right, amazing.");
}
else if ( guess < x)
{
System.out.println(" You were under the correct one which is " + x);
}
else if ( guess > x)
{
System.out.println("You were over, it actually was " + x);
}
else
{
System.out.print("Your bad");
}
}
}
Picture of the output