Need assistance with Min and Max function?
<p>I have an application a number guess game, users have to guess a number between 0 and 100, when they guess right the program asks them if they would like to play again when their done play I display the least number of guesses in a game and the greatest number of guess in a game. Right now all i get is the sum of all their guesses in the when using the "Math.min(,)"?
How do I get the minimum function to work??? the function code is in further below.</p>

<ol>
<li><p><strong>leastNumGuesses = Math.min(leastNumGuesses,guesses);</strong></p>

<pre><code>double rightNum = Math.random() *100;
int randomNum = (int) rightNum; //convert the random number to int
int tries = 0; //single game gussess output
int numberOfGames = 0;
int allTries = 0; //accumalates all tries(sum of all tries)
int guesses = 0; // guesses of all games combined
int gameGuesses = 0;
int leastNumGuesses = 100;
int mostNumGuesses = 0;


  while (choice.equalsIgnoreCase("y"))
</code></pre>

<p>{</p>

<pre><code>   System.out.println();

   int guess = getIntWithinRange(sc,"Enter the Number: ", 0, 100);
   tries++;
   guesses++;
   gameGuesses++;

   if (guess == randomNum)
   {
       numberOfGames++;
       System.out.println("You got it in " + tries + " tries.");
       leastNumGuesses = Math.min(leastNumGuesses,gameGuesses);
       if (tries &lt;=3)
                System.out.println("Great work! You are a mathematical wizard.");
       else if (tries &gt; 3 &amp;&amp; tries &lt;= 7)
                System.out.println("Not too bad! You've got some potential.");
       else if (tries &gt; 7)
                System.out.println("What took you so long? Maybe you should take some lessons.");

       System.out.println();      
       System.out.println("Would you like to play again (y/n):");
       choice = sc.nextLine();

   while (!choice.equalsIgnoreCase("n") &amp;&amp; !choice.equalsIgnoreCase("y"))
    {

   System.out.println("Error! entry must be \"y\" or \"n\".");
   System.out.println("Would you like to play again (y/n):");
   choice = sc.nextLine();
    }   

       if (choice.equalsIgnoreCase("y"))       
       {    // reset the random number &amp; tries

          rightNum = Math.random() *100;
            randomNum = (int) rightNum;
            tries=0;
           gameGuesses++;
       }
       else if (choice.equalsIgnoreCase("n"))
       {    
          allTries += guesses;
          int averageNumGuess = allTries / numberOfGames;

           System.out.println("Bye - Come back again");
           System.out.println("Number of Games Played: " + numberOfGames);
           System.out.println("Average Number of Guesses: " + averageNumGuess);
           System.out.println("Least Amount of Guesses In a Single Game: " + leastNumGuesses);

       }

   }
</code></pre></li>
</ol>
