Hey guys I have been doing an assignment first time I have used Java and I am not sure why my while statements dont seem to work? What I am trying to do is to re-ask a user a question if they enter a false answer. There are only two correct answers blue or white and if they enter purple I want it to be re-asked. Could anyone give me some help with this?
Thanks, complete newb to java I rarely ask for help when it comes to things but this is something that confuses me.Code:System.out.println("Please choose a colour, blue or white?");
colour = scanner.nextLine();
colour = colour.toLowerCase(); // Changes the case of the String colour to lower case rather than ignoring it
if (colour.equals("white"))
{
System.out.println("Hello " + forename + " " + surname + ", Swansea City play in white.");
}
else if (colour.equals("blue"))
{
System.out.println("Hello " + forename + " " + surname + ", Cardiff City play in blue.");
}
else
{
System.out.println("Sorry," + forename +", I did not understand you");
}
}
}

