Assignment #58 and OneShotHiLo
Code
/// Name: Jason Kim
/// Period: 7
/// Program Name: OneShotHiLo
/// File Name: OneShotHiLo.java
/// Date Finished:10/29/15
import java.util.Random;
import java.util.Scanner;
public class OneShotHiLo
{
public static void main (String[]args)
{
Random r = new Random();
Scanner keyboard = new Scanner(System.in);
int number, guess;
number = 1 + r.nextInt(100);
System.out.println("I'm thinking of a number between 1-100. Try to guess it. ");
guess = keyboard.nextInt();
if ( guess < number )
{
System.out.println("Sorry, you are too low. I was thinking of " + number + ".");
}
else if (guess > number )
{
System.out.println("Sorry, you are too high. I was thinking of " + number + ".");
}
else
{
System.out.println("You guessed it! What are the odds?!?");
}
}
}
Picture of the output