I am trying to generate a random number larger than and smaller than the previous random number, but cannot figure out how.
I have this so far:
number = (int)( max * Math.random() ) + min;
guess = (int)( max * Math.random() ) + min;
if (guess<number)
{
guess = (int)( max * Math.random() ) + min;
System.out.println(guess);
}
else if (guess>number)
{
guess = (int)( max * Math.random() ) + min;
System.out.println(guess);
}
UPDATE: How do I make sure it doesn't generate a random number that it already has generated? The computer gets 10 tries to guess the number that was generated, but I want to make it logical in the way that it wouldn't generate one that it already knows is wrong.