Assignment #58 and One Shot Hi-Lo
Code
/// Name: Graham Pollock
/// Period: 5
/// Program Name: One Shot Hi-Lo
/// File Name: HiLo.java
/// Date Finished: 12/03/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 snumber, guess;
snumber = 1 + r.nextInt(100);
System.out.println("I'm thinking of a number between 1-100. try to guess it!");
System.out.print("> ");
guess = keyboard.nextInt();
System.out.println("");
if (guess == snumber)
{
System.out.println("congrats! You guessed right!");
}
else if (guess > snumber)
{
System.out.println("you guessed too high");
}
else if (guess < snumber)
{
System.out.println("You guessed too low");
}
}
}
Picture of the output