Assignment #68 and Sixty-Five Program

Code

        /// Name: Georgi Atanasov
        /// Period: 5
        /// Program Name: Reverse Hi-Lo
        /// File Name: ReverseHiLo.java
        /// Date Finished: 1/8/2016
    
    import java.util.Scanner;

    public class ReverseHiLo
    {
        public static void main(String[] args)
        {
            Scanner keyboard = new Scanner(System.in);
            
            int hi = 1000;
            int lo = 1;
            int guess = (hi + lo)/2;
            String answer;
            
            System.out.println("Think of a number from 1 to 1000. I'll try to guess it.");
            System.out.println("My guess is " + guess + ". Am I too (h)igh, too (l)ow, or (c)orrect?");
            answer = keyboard.next();
            
            while (! answer.equals("c"))
            {
                if (answer.equals("h"))
                    hi = guess;
                else if (answer.equals("l"))
                    lo = guess;
                
                guess = (hi + lo)/2;
                
                System.out.println("My guess is " + guess + ". Am I too (h)igh, too (l)ow, or (c)orrect?");
                answer = keyboard.next();
            }
            
            System.out.println("Ha! I am the greatest guesser in the WORLD!");
        }
    }
    

Picture of the output

Assignment 68