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