When the program calls the getValidString it won't display "Judge Another? (y/n)"
It seems like everything should work I just can't figure it out

//see if the user would like to continue
choice = getValidString(sc,"Judge Another? (y/n): ", "y" , "n" );


private static String getValidString(Scanner sc, String prompt, String s1, String s2)
{
    String s = "";
    boolean isValid = false;
    while(isValid ==false)
    {
        s = getString(sc,prompt);
        if(s.equalsIgnoreCase("y") || s.equalsIgnoreCase("n"))
        {
            isValid = true;
        }//end if
        else
        {
            System.out.println("Error! Please enter '" + s1 + "' or'" + s2 + "'.");
        }//end else
    }//end while
    return s;
}//end getValidString

private static String getString(Scanner sc, String prompt)
{
    String s = "";
    boolean isValid = false;
    while (isValid == false);
    {
        System.out.print(prompt);
        s = sc.nextLine();
        if (s.equals(""))

            System.out.println("Error! Entry Required.");

        else

            isValid = true;

    }//end while
    return s;
}//end getString

post in code tags and post all of your code.

post in code tags and post all of your code.

im also having the same problem

What - that you can't post in code tags?

im also having the same problem

1

You must have missed the forum rules and the 'create new thread' button at the top of the forum. Shame.

What - that you can't post in code tags?

i dont know where to put the validation when i ask the user to continue

No, as I tried to explain, your problem is that you don't know how to start a new thread rather than interrupting someone else's. To help you out: http://tinyurl.com/yzgjk68 . Go do that and click on the first link. Read carefully.

No, as I tried to explain, your problem is that you don't know how to start a new thread rather than interrupting someone else's.

let me delete my posts and ill start a new thread.

ive created a new thread called string validation help 2. if you dont mind, can you please go to it and help me?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.