Assignemnt #58 and Hi-Lo
Code
/// Name: Yordan Rashkov
/// Period: 7
/// Program Name: Hi-Lo
/// File Name: Hi-Lo.java
/// Date Finished: 11/27/2015
import java.util.Random;
import java.util.Scanner;
public class HiLo
{
public static void main ( String[] args )
{
Random r = new Random();
Scanner keyboard = new Scanner(System.in);
int h, x = 1 + r.nextInt(100);
System.out.println("I'm thinking of a number between 1-100. try and guess it");
System.out.print("> ");
h = keyboard.nextInt();
if ( x == h)
{
System.out.println("I cannot believe it, you got it. It was " + x);
}
if ( x > h )
{
System.out.println("Sorry you are too low. It was " + x);
}
if ( x < h )
{
System.out.println("Sorry you are too high. It was " + x);
}
}
}