Improve the CityTravel program by prompting the user to enter origin and destination cities and using the

Question:

Improve the CityTravel program by prompting the user to enter origin and destination cities and using the user-entered values in the getDistance method call. If the user does not spell one of the enumerated cities correctly, print an error message and loop until one of the enumerated cities is entered correctly. Do this by providing a new method with this signature:

public static City getCity(String originOrDestination)

And in the modified main method, replace:City origin = City.PARKVILLE;

City destination = City.KINGSTON; 

with this:

City origin = getCity("origin");

City destination = getCity("destination");

  1. Sample session: Enter origin city (PARKVILLE, HAVANA, KINGSTON, NASSAU, or SAINT THOMAS): Parkville Invalid

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: