Question: Your program must respond to the follow command as described below: Q 1 - A Command: areneighbours Parameters: 2 integers Behaviour: The system must read

Your program must respond to the follow command as described below:
Q1-A
Command: areneighbours
Parameters: 2 integers
Behaviour: The system must read in two integers from the standard input stream then output
a Yes if the two cities represented by those numbers are neighbours or No otherwise.
Expected output on test data with input (0,1): Yes
Expected output on test data with input (1,2): No
Expected output on test data with input (3,4): Yes
Expected output on test data with input (0,4): Yes
Q1-B
Command: ispath
Parameters: A set of integers ending in a negative number
Behaviour: The system must read in a set of city numbers from the standard input stream
until it encounters a negative number. It must then say if the set of cities are connected by a
valid path by either outputting Yes or No
Expected output on test data with input (0,1,3,4,-1): Yes
Expected output on test data with input (0,1,2,3,4,-1): No
Expected output on test data with input (0,3,4,-1): Yes
Expected output on test data with input (0,2,3,1,4,-1): Yes
Q1-C
Command: pathlength
Parameters: A set of integers ending in a negative number
Behaviour: The system must read in a set of city numbers from the standard input stream
until it encounters a negative number. It must then output the total distance along the path
connecting those cities. You may assume the path is valid.
Expected output on test data with input (0,1,3,4,-1): 1.8
Expected output on test data with input (0,3,4,-1): 1.4
Expected output on test data with input (0,2,3,1,4,-1): 2.5
Q1-D
Command: listneighbours
Parameters: 1 integer
Behaviour: The system must read in a city number from the standard input stream and then
output all of the cities which are directly connected to it (in ascending numerical order)
Expected output on test data with input (0): 1234
Q1-E
Command: largestdistance
Parameters: 1 integer
Behaviour: The system must read in a city number from the standard input stream and then
output the largest distance to one of its neighbouring cities.
Expected output on test data with input (0): 0.5
Expected output on test data with input (1): 0.8
Expected output on test data with input (2): 0.6
Expected output on test data with input (3): 0.9
Expected output on test data with input (4): 0.9
Q1-F
Command: isvalid
Parameters: None
Behaviour: The system assumes that distances are the same in both directions (e.g. the
distance from City 0 to City 1 is the same as City 1 to City 0). The system must output Yes if
this is true for all City pairs and No otherwise
Expected output on test data: Yes
Q1-G
Command: pathsfromto
Parameters: 2 integers
Behaviour: The system must read two integer parameters from the standard input stream and
then output the number of non-cyclic paths from the city specified by the first parameter to the
city specified by the second parameter.
Expected output on test data with input (0,4): 5
Q1-H
Command: mostconnected
Parameters: None
Behaviour: The system must output all of the city which share the maximum number of direct
connections (ignoring distances).
Expected output on test data: 03
 Your program must respond to the follow command as described below:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!