title: Generate a random number larger or smaller than the previous random number
body: <p>I am trying to generate a random number larger than and smaller than the previous random number, but cannot figure out how.</p>
  
  <p>I have this so far:</p>
  
  <pre><code>number = (int)( max * Math.random() ) + min;
  guess = (int)( max * Math.random() ) + min;
  if (guess&lt;number)
     {
        guess = (int)( max * Math.random() ) + min;
        System.out.println(guess);
      }
  else if (guess&gt;number)
   {
        guess = (int)( max * Math.random() ) + min;
       System.out.println(guess);
   }
  </code></pre>
  
  <p>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.</p>