this code is supposed to have you pick a # then by telling the pc is its to low or too high you lower the range of the pc's guess but the range does not seem to change could someone help `enter code here.:
int min = 1;
int max = 100;
Scanner i = new Scanner(System.in);
System.out.println("whats the number");
int ans = i.nextInt();
int guess = (int)(Math.random()* 100 + 1);
while(ans != guess)
{
System.out.println(guess);
System.out.println("is that number to high)1 or to low)2");
int p = i.nextInt();
if(p == 1)
{
if(guess < max)
{
max = guess;
guess = (int)(Math.random()*max + min);
}
else
{
guess = (int)(Math.random()*max + min);
}
}
if(p == 2)
{
if(guess > min)
{
min = guess;
guess = (int)(Math.random()*max + min);
}
else
{
guess = (int)(Math.random()*max + min);
}
}
}
System.out.println(guess + " is right");