Assignemnt #68 and reverse.java
Code
/// Name: Boris Kazantsev
/// Period: 6
/// Program Name: reverse
/// File Name: reverse.java
/// Date Finished: 1/14/2016
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