Assignment #58 One Shot Hi-Lo

Code

    /// Name: Matthew Lorence
    /// Period: 5
    /// Program Name: HiLo
    /// File Name: HiLo.java
    
    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 x = 1 + r.nextInt(100);
            
            System.out.println("I'm thinking of a number between 1-100. Try to guess it.");
            int guess = keyboard.nextInt();
            
            if ( x == guess)
            {
                System.out.println("You guess it! What are the ods?!?");
            }
            if (x < guess)
            {
                System.out.println("Sorry you are too high. I was thinking of " + x + ".");
            }
            if (x > guess)
            {
                System.out.println("Sorry you are too low.  I was thinking of " + x + ".");
            }
        }
    }
        
                
        
    

Picture of the output

Assignment 58