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