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");
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Introduction To Programming With Java A Problem Solving Approach
ISBN: 9781260575248
3rd International Edition
Authors: John Dean
Question Posted: