Assignment #58 One Shot Hi-Lo

Code

    /// Name: Koosha Kimelman
    /// Period: 7
    /// Program Name: One Shot Hi-Lo
    /// File Name: HighLow.java
    /// Date Completed: 11/6/15
    
    import java.util.Random;
    
    import java.util.Scanner;
    
    public class HighLow {
    
        public static void main(String[] args) {
        
            Scanner keyboard = new Scanner(System.in);
            
            Random r = new Random();
            
            int answer, guess;
            
            answer = (1+r.nextInt(100));
            
            System.out.println("I got a number between (but still including) 1 and 100. Try to guess it.");
            System.out.print("Your guess: ");
            guess = keyboard.nextInt();
            
            System.out.println();
            
            if (guess == answer)
                System.out.println("Wow you actually got it. Nice guess.");
            else if (guess != answer && guess >= 1 && guess <= 100) {
                if (guess > answer)
                    System.out.println("You guessed too high. The correct answer was " + answer);
                else if (guess < answer)
                    System.out.println("You guessed too low. The correct answer was " + answer);
            }
            else
                System.out.println("You didn't even guess within the given range. Come on, that was the easy part.");
        }
    }
            
    

Picture of the output

Assignment 58