Assignemnt #58 One Shot Hi-Lo

Code

    Name: Iaroslav Titov
    Period: 7
    Project Name: HiLo
    File Name: HiLo.java
    Date: 11/9/2015
    
import java.util.Scanner;
import java.util.InputMismatchException;
import java.util.Random;

       public class HiLo
	   {
		   public static void main(String[] args)
		   {
			   Scanner keyboard = new Scanner(System.in);

			   Random r = new Random();

			   byte guess = 0;
			   byte SN = (byte)(1 + r.nextInt(100));
				try
				{
					System.out.print("I'm thinking of a number from 1 to 100.\nTry to guess it: ");
					guess = (byte) keyboard.nextInt();
				}
				catch (InputMismatchException e)
			   {
				   System.out.println("WRONG INPUT!!!");
			   }
			   System.out.println();

				if(SN==guess) System.out.println("You guessed it!!! You must have cheated somehow!");
				else if (SN < guess) System.out.println("Nope, you guessed too high! Answer was "+SN+".");
				else System.out.println("Nope, you guessed too low! Answer was "+SN+".");

			   System.out.println();
		   }
	   }




    

Picture of the output

Assignment 55