Assignemnt #68 and Reverse Hi-Lo
Code
///Name: Luke Shin
///Period: 7
///Project Name: reverse
///File Name: reverse.java
///Date: 12/14/2015
import java.util.Scanner;
import java.util.Random;
public class reverse{
public static void main(String[] args){
Scanner keyboard = new Scanner(System.in);
int hi=1001, lo=0, guess = 0;
String ans= "";
do {
guess = (lo + hi)/2;
if (guess==0) guess = 1;
System.out.println("Nubmer: "+guess);
System.out.print("Is it too high (h), low (l), or correct (c)? ");
ans = keyboard.next();
switch(ans)
{
case "h": hi = guess;
break;
case "l": lo = guess;
break;
case "c": ans = "ans";
break;
default : System.out.print("nope");
}
}
while (!ans.equals("ans"));
}
}
Picture of the output