Try the following code instead of one that you have written
CODE
public static boolean askForAnotherRound(String prompt)
{
while(true)
{
String Answer;
System.out.println("\n" + prompt + " (Y or N) ");
answer = sc.next();
if(answere.equalsIgnoreCase("Y"))
continue;
else if (answer.equalsIgnoreCase("N"))
break;
}
}
EDIT: PLEASE USE CODE TAGS
Problems with the earlier code was
i) the RETURN statement that will cause the program to return from that function to calling function
ii) the same as with the second RETURN statement also.
iii) I think you want to continue when the input is "Y" and exit the loop while
the input is "N".
iv) So, I have replaced those two statements with CONTINUE and BREAK statements respectively.
This post has been edited by PennyBoki: 26 Aug, 2007 - 11:27 PM