How can i write this in code?
Trip Summary:
Currently No Stops
Total Tour Distance: 0.0 miles
MENU
A) Add a city onto tour
I) Insert a city into the tour
R) Remove a stop from the tour
Q) Quit
Selection: A
Cities to Choose From:
1) Austin, TX
2) Baltimore, MD
3) Boston, MA
4) Chicago, IL
5) Cleveland, OH
6) Columbus, OH
7) Dallas, TX
8) Denver, CO
9) Detroit, MI
10) El Paso, TX
Selection: 1
Trip Summary:
1. Austin, TX (30� 18' N, 97� 42' W)
Total Tour Distance: 0.0 miles
---
any advice or help is appreciated.
Re: How can i write this in code?
can anyone please help me? or at least how to start or an outline? thank you so much in advance.
Re: How can i write this in code?
First, you'd need a list of all those cities you had, the distances between them, a simple map data structure (also known as a graph) that you can use to traverse which cities are more-or-less directly connected to each other.
For information about the map data structure, see Wikipedia Graph (data structure).
Once you have the cities in the graph correctly, you can traverse between any two points using Dijkstra's algorithm. If the order added is the order you want to visit them in, just run Dijkstra's algorithm multiple times between all the city pairs and sum up the mileage.