Can't call validation methods in Java
<p>I have this problem, I created two methods that validate the users input. Then I am trying to get their input to validate before the rest of the program is run. It won't work and I can't find any thing online that will help.</p>

<p>I did it in another program the exact same way, yet it won't work in this one. Any help would be much appreciated.</p>

<p>(the main section is commented out because I was trying to get it run)...</p>

<pre><code>    import java.util.*;




public class GuessingGame {

/**
 * @param args
 */
public static void main(String[] args) {
    // TODO Auto-generated method stub



    int answer;
    int tries = 0;
    answer = (int) (Math.random() * 99 + 1);



    System.out.println("Welcome to the Guess the Number Game ");
    System.out.println("+++++++++++++++++++++++++++++++++++++ \n");
    System.out.println("I'm thinking of a number between 1-100 ");
    System.out.println("Try to guess it! ");

    Scanner sc = new Scanner(System.in);
    String choice = "y";

while (choice.equalsIgnoreCase("y"))    
{



        int guess = getIntWithinRange(sc, "Enter number: ", 0, 100);




        /**

        if (guess == answer) 
        {
            System.out.println("Your guess is correct! Congratulations!");
        }
        else if (guess &gt; answer + 10)
            { System.out.println("Your guess was way too high");
            tries++;
            }

        else if (guess &lt; answer)
            { System.out.println("Your guess was too low. Try again. ");
            tries++;
            }

        else if (guess &gt; answer)
            {System.out.println("Your guess was too high. Try again.");
            tries++;
            }



                System.out.println("The number was " + answer + " !");
                System.out.println("You guessed it in " + tries + " tries");

                    if (tries &lt; 2)
                        {System.out.println("That was lucky!");
                        }

                    if (tries &gt;=2 &amp;&amp; tries &lt;=4)
                        {System.out.println("That was amazing!");
                        }

                    if (tries &gt; 4 &amp;&amp; tries &lt;= 6)
                        {System.out.println("That was good.");
                        }

                    if (tries &gt;= 7 &amp;&amp; tries &lt;=7)
                        {System.out.println("That was OK. ");
                        }

                    if (tries &gt; 7 &amp;&amp; tries &lt; 10)
                        { System.out.println("That was not very good. ");
                        }

                    if (tries &gt;= 10)
                        {System.out.println("This just isn't your game. ");
                        }
                **/ 

                      //ask if they want to continue
                    System.out.println("\n Continue (y/n)? ");
                    choice = sc.next();
                    sc.nextLine();
                    System.out.println();

    }

    //print out thank you message
    System.out.println("Thanks for finding the common divisor ");
    sc.close();
}

public static int getInt(Scanner sc, String prompt)
{
    int i = 0;
    boolean valid = false;

    while(valid == false);
    {   
        System.out.println(prompt);
        if (sc.hasNextInt())
        {
            i = sc.nextInt();
            valid = true;
        }
        else
        {
            System.out.println("Please enter a number... ");
        }
        sc.nextLine();
    }
    return i;

}








public static int getIntWithinRange(Scanner sc, String prompt, int min, int max)
{
    int i = 0;
    boolean valid = false;

    while (valid == false)
    {
        i = getInt(sc, prompt);
        if (i &lt;= min || i &gt;= max)
            System.out.println("Number must be between 1-100 ");
        else
            valid = true;
    }
    return i;
}
</code></pre>

<p>}</p>
