Assignment #58

Code

    ///Name: Cody Swain
    ///Period: 6
    ///Project Name: HiLo
    ///File Name: hiLo.java
    ///Date: 11/13/15
    
    import java.util.Scanner;
    import java.util.Random;
    
    public class HiLo
    {
        public static void main( String[] args )
        {
            Scanner keyboard = new Scanner(System.in);
            Random r = new Random();
            int guess, number = 1 + r.nextInt(100);
            
            
            System.out.println( "I'm thinking of a number between 1-100. Try to guess it. ");
            guess = keyboard.nextInt();
            
            if ( guess == number )
                System.out.println( "Wow Good Job, that is correct! ");
            else if ( guess < number )
                System.out.println( "Sorry, you are too low. I was thinking of " + number );
            else if ( guess > number )
                System.out.println( "Sorry you are too high. I was thinking of " + number );
            else System.out.println( "Error.");
            
        }
    }
            

        
    

Picture of the output

Assignment 58