Assignment #58 and OneShotHiLo
Code
/// Name: Tim Chuang
/// Period: 7
/// Program Name: OneShotHiLo
/// File Name: OneShotHiLo.java
/// Date Finished: 12/4/2015
import java.util.Random;
import java.util.Scanner;
public class OneShotHiLo
{
public static void main ( String[] args )
{
int guess;
Random r = new Random();
Scanner keyboard = new Scanner(System.in);
int theNumber = 1 + r.nextInt(100);
System.out.println("Whats a number between 1 and 100?");
System.out.print("> ");
guess = keyboard.nextInt();
if ( guess == theNumber )
System.out.println("Wwwwwaooooo gg");
else if ( guess > theNumber )
System.out.println("Thats too high, it was " + theNumber + ".");
else if ( guess < theNumber )
System.out.println("Thats too low, it was " + theNumber + ".");
else
System.out.println("lol nope");
}
}
Picture of the output