/** * Created by iyasuwatts on 10/17/17. */ import java.util.*; public class Main { public static void main(String[] args){ Random answer = new Random(); Scanner input = new Scanner(System.in); System.out.println("Enter Your lower range"); int min = input.nextInt(); System.out.println("Enter Your higher range"); int max = input.nextInt(); System.out.println("Enter a number between " + min + " and " + max); int guess = input.nextInt(); int finAnswer = answer.nextInt((max-min)+1) + min; int count = 1; while(guess != finAnswer){ if(guess > finAnswer){ System.out.println("Sorry its too large please try again"); int prev = guess; guess = input.nextInt(); if(guess != prev ){ count += 1; } } else if(guess < finAnswer){ System.out.println("Sorry its too small please try again"); int prev = guess; guess = input.nextInt(); if(guess != prev ){ count += 1; } } } System.out.println("Good Job, you got it in "+ count + " tries"); } }