Assignemnt #68: Reverse Hi-Lo

Code

    ///Name: Cassie
    ///Period: 6
    ///Program Name: Reverse Hi-Lo
    ///File Name: reverse.java
    ///Date Finished: 1/11/16
    
    import java.util.Scanner;
    class reverse
    {
        public static void main ( String[] args )
        {
            Scanner keyboard = new Scanner(System.in);
            int guess, hi=1000, lo=1;
            String rep="";
            System.out.println( "Think of a number between 1 and 1000." );    
            while ( !rep.equals("c") )
            {
                guess = (hi+lo)/2;
                System.out.println( "My guess is " + guess + ". (h)igh, (l)ow, or (c)orrect?" );
                rep = keyboard.next();
                if ( rep.equals( "h" ) )
                    hi = guess;
                if ( rep.equals( "l" ) )
                    lo = guess;
            
            }
    
            System.out.println( "Knew it!" );
    
        }
    }
    

Picture of the output

Assignment 68