Program in C. Help please! Write some code in the main() function to accomplish the following tasks: Read the supplied data from datafile city.dat Build an adjacency matrix based on the city.dat datafile Create an alphabetized list of cities for selection by the user Display the cities from which to select using a number that your program assigns from the alphabetized list of cities that is dynamically created from your city.dat file. Example: Please select an origin city Enter a number associated with one of the cities below: Amsterdam --- 1 Belgrade --- 2 Bern --- 3 Genoa --- 4 Hamburg --- 5 Lisbon --- 6 Madrid --- 7 Having written code to extract data from the keyboard (stdin) in Lab 3, reuse that code to prompt the user to enter a number, verifying that the number entered is an integer and is between 0 and the maximum number of available cities in the list. You should ignore any invalid entries such as float values, letters, punctuation, whitespace, etc.
Program in C. Help please!
Write some code in the main() function to accomplish the following tasks:
Read the supplied data from datafile city.dat
Build an adjacency matrix based on the city.dat datafile
Create an alphabetized list of cities for selection by the user
Display the cities from which to select using a number that your program assigns from the alphabetized list of cities that is dynamically created from your city.dat file.
Example: Please select an origin city Enter a number associated with one of the cities below: Amsterdam --- 1 Belgrade --- 2 Bern --- 3 Genoa --- 4 Hamburg --- 5 Lisbon --- 6 Madrid --- 7
Having written code to extract data from the keyboard (stdin) in Lab 3, reuse that code to prompt the user to enter a number, verifying that the number entered is an integer and is between 0 and the maximum number of available cities in the list. You should ignore any invalid entries such as float values, letters, punctuation, whitespace, etc.
Display the above list of cities and have the user select an origin city from the list
Display the above list of cities, removing the city selected as the origin city, and have the user select a destination city from the list
Apply Dijkstra's
Report three items on the screen: 1. the names of the two selected cities identified, such as: ORIGIN: Lisbon DESTINATION: Warsaw
2. the length of the optimal path, such as: LENGTH: 1629
3. the list of the cities visited along the optimal path, like:
PATH CITIES: Lisbon Madrid Genoa Trieste Vienna Warsaw
Continue to ask for two cities to map until the user selects 0
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images