Assignemnt #68

Code

          /// Name: Holden Ganch
          /// Period: 7
          /// Program Name:  sixty eigth Program
          /// File Name: Reverse.java
          /// Date Finished: 12/14/2015


    
        import java.util.Random;
        import java.util.Scanner;
        
        public class Reverse
        {
            public static void main( String[] args )
            {
                Random r = new Random();
            Scanner keyboard = new Scanner(System.in);
            int hi = 1000;
            int low = 1;
            int average = (hi + low)/2;
            String x;
            
            System.out.println("Think of a number between 1 and 1000 and i will try and guess it.");
            System.out.println("My guess is " + average + ". Am i to (h)igh, to (l)ow, or (c)orrect");
            System.out.print("> ");
            x = keyboard.next();
            System.out.println("");
            
            while (!x.equals("c"))
            {
            if (x.equals("h"))
            {
            hi = average;
            average = (hi + low)/2;
            System.out.println("My guess is " + average + ". Am i to (h)igh, to (l)ow, or (c)orrect");
            System.out.print("> ");
            x = keyboard.next();
             System.out.println("");
            }
            else if (x.equals("l"))
            {
            low = average;
            average = (hi + low)/2;
            System.out.println("My guess is " + average + ". Am i to (h)igh, to (l)ow, or (c)orrect");
            System.out.print("> ");
            x = keyboard.next();
             System.out.println("");
            }
            }
            
            System.out.println("I got it. Impressed? Why not?");
            System.out.println("ARE YOU NOT ENTERTAINED!!!!!!!!");
            
           
               
            }
            }
    
   




    

Picture of the output

Assignment 68