Assignemnt #58 and One Shot Hi Lo
Code
/// Name: Raff Lisbona
/// Period: 6
/// Program Name: One Shot Hi Lo
/// File Name: OneShotHiLo.java
/// Date Finished: 11/17/2015
import java.util.Random;
import java.util.Scanner;
public class OneShotHiLo
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
Random r = new Random();
int guess, number;
number = 1 + r.nextInt(100);
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 ( number == guess )
System.out.println("You guessed it! I am very impressed!!!");
else if ( guess > number )
System.out.println("Sorry you are too high. I was thinking of " + number + ".");
else if ( guess < number )
System.out.println("Sorry you are too low. I was thinking of " + number + ".");
}
}
Picture of the output