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
![1 Lisbon Madrid 339
2 Naples Rome 134
3 Hamburg Copenhagen 180
4 Hamburg Berlin 182
5 Berlin Warsaw 345
6 Amsterdam Hamburg 338
7 Amsterdam Brussels 164
8 Berlin Prague 219
9 Prague Warsaw 479
10 Prague Vienna 185
11 Munich Prague 174
12 Vienna Warsaw 464
13 Vienna Budapest 155
14 Warsaw Budapest 394
15 Budapest Belgrade 263
16 Vienna Belgrade 501
17 Budapest Trieste 384
18 Trieste Vienna 317
19 Trieste Belgrade 403
20 Munich Vienna 280
21 Munich Rome 582
22 Genoa Trieste 361
23 Genoa Rome 328
24 Trieste Rome 442
25 Paris Genoa 629
26 Genoa Bern 304
27 Genoa Brussels 740
28 Bern Brussels 497
29 Amsterdam Bern 558
30 Amsterdam Munich 526
31 Bern Munich 311
32 Bern Trieste 489
33 Bern Madrid 1104
34 Madrid Genoa 951
35 Madrid Paris 805
36 Paris Brussels 225](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fa10af158-0874-4694-936f-dae8e18f7216%2F016ac987-4bfe-4b0e-bc60-cc59b16da2b5%2F0ycr4j9_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)