
public class loopDemo6 {
	public static void main(String[] args) {
		// Required variables:
		// int 		- (our guess number)
		// String	- to hold the user's response of "yes" or "no"
		int guess = 0;
		String response="no";
		
		// ask the user for bounds on their 'secret' number
		System.out.println("What's an integer number lower than your secret number? ");
		int lower = Keyboard.readInt();
		System.out.println("What's an integer number higher than your secret number? ");
		int higher = Keyboard.readInt();
		
		
		// Required code:
		// loop		- continually updating the guess number
		//			  and asking user if that number is correct
		while(lower < higher){
			guess = (higher-lower)/2 + lower;
			System.out.println("\n\n Lower bound: "+lower+"  Upper bound: "+higher);
			System.out.println("Is you number <= "+guess+" (yes/no)? ");
			response = Keyboard.readString();
			
			if(response.equals("yes")){
				higher = guess;
			}
			else{
				lower = guess+1;
			}
		}
		
	
		// response to user indicating when we've found their number
		System.out.println("\n\n Lower bound: "+lower+"  Upper bound: "+higher);
		System.out.println("Your number was "+lower);
	}
}
