Write a program to print the driving time between two towns in Kedah. The graph that connects these towns is shown in Figure 1. Use adjacency matrix to represent the graph.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 20PE
icon
Related questions
Question
Write a program to print the driving time between two towns in Kedah. The graph that
connects these towns is shown in Figure 1. Use adjacency matrix to represent the graph.
O Bukit Kayu Hitam
1 Alor Setar
2 Sungai Petani
3 Gurun
4 Kulim
35 min
62 min
70 min
50 min
5 Baling
43 min
2
61 min
Figure 1
The program should:
a) Print the list of towns using a function called printTowns
b) Prompt user to key in an origin and destination town
c) Print the driving time between the towns. If there are no direct route, print "No direct
route"
An example of the output is shown in Figure 2.
Towns
1
Bukit Kayu Hitam
Alor Setar
2
Sungai Petani
Gurun
4
Kulim
5
Baling
Origin: 2
Destination: 4
Sungai Petani to Kulim: 50 minutes
Figure 2
Transcribed Image Text:Write a program to print the driving time between two towns in Kedah. The graph that connects these towns is shown in Figure 1. Use adjacency matrix to represent the graph. O Bukit Kayu Hitam 1 Alor Setar 2 Sungai Petani 3 Gurun 4 Kulim 35 min 62 min 70 min 50 min 5 Baling 43 min 2 61 min Figure 1 The program should: a) Print the list of towns using a function called printTowns b) Prompt user to key in an origin and destination town c) Print the driving time between the towns. If there are no direct route, print "No direct route" An example of the output is shown in Figure 2. Towns 1 Bukit Kayu Hitam Alor Setar 2 Sungai Petani Gurun 4 Kulim 5 Baling Origin: 2 Destination: 4 Sungai Petani to Kulim: 50 minutes Figure 2
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L