Why not create a map where the zone is the key and the value is a list of stations that come under that zone?
You can then have a method that handles the population of the map...
private static Map<String, List<String>> createZoneMap() {
Map<String, List<String>> zoneMap = new HashMap<String, List<String>>();
// Probably want to populate this map from a file
return zoneMap;
}
Then your main can look something like...
public static void main(String args[]) {
Map<String, List<String>> zoneMap = createZoneMap();
Scanner scan = new Scanner(System.in);
String input;
while (true) {
input = scan.nextLine();
// Some code to exit the application...
if (input.equalsIgnoreCase("quit")) {
System.out.println("Exiting...");
System.exit(1);
}
String zone = findZone(zoneMap, input);
if (zone != null) {
System.out.println(input + " is in " + zone);
} else {
System.out.println("That is not a Station, please try again");
}
}
}
Then when you type in the station name you look through the map to find the zone which the station comes under, if its not present then return null or something
private static String findZone(Map<String, List<String>> zoneMap, String station) {
// Maybe make this more versatile so that it does not care about case...
for (Map.Entry<String, List<String>> entry : zoneMap.entrySet()) {
if (entry.getValue().contains(station)) {
return entry.getKey();
}
}
return null;
}
Hope that's a good starting point for you. You could also consider moving away from performing all of your logic in the main method and instead create an instance of your class in the main.