Assignment #58 and One Shot Hi-Lo
Code
/// Name: Ali Kurland
/// Period: 6
/// Program Name: One Shot Hi-Lo
/// File Name: OneShotHiLo.java
/// Date Finished: 10/8/2015
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 = 1 + r.nextInt(100);
int guess;
System.out.println( "I'm thinking of a number between 1-100. Try to guess it." );
System.out.print( "> " );
guess = keyboard.nextInt();
System.out.println( " " );
if ( guess == number )
System.out.println( "You guessed it! What are the odds?!?" );
else if (guess > number )
System.out.println( "Sorry, you are too high. I was thinking of " + number + "." );
else
System.out.println( "Sorry, you are too low. I was thinking of " + number + "." );
}
}
Picture of the output