Assignemnt #68 and Reverse Hi-Lo Code /// Name: Yordan Rashkov /// Period: 7 /// Program Name: ReverseHiLo /// File Name: ReverseHiLo.java /// Date Finished: 1/11/2016 import java.util.Random; import java.util.Scanner; public class ReverseHiLo { public static void main ( String[] args ) { Random r = new Random(); Scanner keyboard = new Scanner(System.in); int guess, hi, lo; String answer; lo = 1; hi = 1000; guess = ( lo + hi ) / 2; System.out.println(); System.out.println(); System.out.println("Think of a number from 1 to 1000. I'll try to guess it"); System.out.println(); System.out.println(); System.out.print(" My guess is " + guess + " . Am I too (h)igh, too (l)ow, or (c)orrect? "); System.out.println(); answer = keyboard.next(); System.out.println(); System.out.println(); System.out.println(); while ( !answer.equals("c") ) { if ( !answer.equals("h") ) { hi = guess; guess = ( guess + lo ) / 2; System.out.println(" My guess is " + guess + " . Am I too (h)igh, too (l)ow, or (c)orrect? " ); answer = keyboard.next(); if ( !answer.equals("l") ) { lo = guess; guess = ( guess + hi ) / 2; System.out.println(" My guess is " + guess + " . Am I too (h)igh, too (l)ow, or (c)orrect? " ); answer = keyboard.next(); } } else if ( !answer.equals("l") ) { lo = guess; guess = ( guess + hi ) / 2; System.out.println(" My guess is " + guess + " . Am I too (h)igh, too (l)ow, or (c)orrect? " ); answer = keyboard.next(); if ( !answer.equals("h") ) { hi = guess; guess = ( guess + 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'm surprisingly a smart computer! "); } } }