Assignment #58 One Shot Hi-Lo
Code
///Name: Ian Grant
///Period:5
///Project Name: One Shot Hi-Lo
///File Name:HiLo.java
///11/9/15
import java.util.Scanner;
import java.util.Random;
public class HiLo
{
public static void main(String[] args)
{
Scanner stuff=new Scanner(System.in);
Random r=new Random();
int num,gus;
num=1+r.nextInt(100);
System.out.println("I'm thinking of a number between 1-100. Try to guess it.");
gus=stuff.nextInt();
if (gus==num)
System.out.println("Correct, I was thinking of "+num);
else if (gus>num)
System.out.println("Too high, I was thinking of "+num);
else if (gus< num)
System.out.println("Too low, I was thinking of "+num);
}
}
Output