Assignment 68, Reverse Hi-Lo

Code

   ///Name: Stella Koliavas
   ///Period: 5
   ///File Name: ReverseGuess.java
   ///Date Finshed: 1/10/16
   
   import java.util.Scanner;

    public class ReverseGuess
    {
        public static void main(String[] args)
        {
        
        Scanner siri = new Scanner(System.in);
        
        int h = 1000,l = 1, guess = (h + l)/2, c = 0;
        String ans;
        System.out.println("Think of a number btwn 1 - 1000 and I, the computer will try to guess it");
        System.out.print("I guess " + guess + ". Is that number too (h)igh, (l)ow, or (c)orrect? ");
        ans = siri.next();
        
        
        while (!ans.equals("c"))
        {
            if (ans.equals("h"))
            {
                h = guess;
                guess = (h + l)/2;
                System.out.print("I guess "+ guess + ". Is that number too (h)igh, (l)ow, or (c)orrect? ");
                ans = siri.next();
             }
        
            if (ans.equals("l"))
            {
                l = guess;
                guess = (h + l)/2;
                System.out.print("I guess "+ guess + ". Is that number too (h)igh, (l)ow, or (c)orrect? ");
                ans = siri.next();
        }}
        
           if (ans.equals("c"))
               System.out.println("Yay I guessed it right, I told you the computer always wins!");
    }
    }
    
        
    

Picture of the output

Assignment 68