On the assumption that the user of your program is supposed to use only the provided words for routes, then you can try the following: This assumes you're using JDK 1.7 for switch with strings.
switch(userinput.readLine().toUpperCase()){
case "NORTH":
break;
case "SOUTH":
break;
case "EAST":
break;
case "WEST":
break;
default:
}
However, if you're using JDK 1.6 or below, you can implement your code in the following way:
String input = userinput.readLine().toUpperCase();
if(input.equals("NORTH"))
else if(input.equals("SOUTH"))
else if(input.equals("EAST"))
else if(input.equals("WEST"))
else
However, if neither of the above solutions work for you, you can check
Java's Regular Expressions API[
^] or the
Java's Regular Expression Tutorial[
^].
In case this satisfies your requirements, you can always mark it as an accepted solution and upvote it so that others may also benefit from the same.