i have a question about my program. i have it set up to give an interval if its to high or to low but its a very wide range i was wondering if there was a way to narrow the range down to within like ten of the random number here is the code i have now.
import java.util.Scanner; import java.util.*; public class NumberGame { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Random random = new Random(); int rand = random.nextInt(100); int guesses = 0; int low = 1; int high = 100; System.out.println("I'm thinking of a number between 0 and 100. Whats your guess?"); while (sc.hasNextInt()) { int myGuess = sc.nextInt(); if (myGuess == rand) { guesses++; System.out.println("Congratulations! I was thinking " + rand + ". It took you " + guesses + " guesses."); break; } else if (myGuess < rand) { System.out.println("Try to guess higher.Try Between:"+":"+myGuess+"-"+high); guesses++; } else if (myGuess > rand) { System.out.println("Try to guess lower.Try Between"+":"+myGuess+"-"+low); guesses++; } } } }