12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * Created by iyasuwatts on 10/17/17.
  3. */
  4. import java.util.*;
  5. public class Main {
  6. public static void main(String[] args){
  7. Random answer = new Random();
  8. Scanner input = new Scanner(System.in);
  9. System.out.println("Enter Your lower range");
  10. int min = input.nextInt();
  11. System.out.println("Enter Your higher range");
  12. int max = input.nextInt();
  13. System.out.println("Enter a number between " + min + " and " + max);
  14. int guess = input.nextInt();
  15. int finAnswer = answer.nextInt((max-min)+1) + min;
  16. int count = 1;
  17. while(guess != finAnswer){
  18. if(guess > finAnswer){
  19. System.out.println("Sorry its too large please try again");
  20. int prev = guess;
  21. guess = input.nextInt();
  22. if(guess != prev ){
  23. count += 1;
  24. }
  25. } else if(guess < finAnswer){
  26. System.out.println("Sorry its too small please try again");
  27. int prev = guess;
  28. guess = input.nextInt();
  29. if(guess != prev ){
  30. count += 1;
  31. }
  32. }
  33. }
  34. System.out.println("Good Job, you got it in "+ count + " tries");
  35. }
  36. }