P2 Cities Part 1 – Arrays – City Distances Consider the following X…
Question Answered step-by-step P2 Cities Part 1 – Arrays – City Distances Consider the following X… P2 Cities Part 1 – Arrays – City DistancesConsider the following X and Y values for the locations of 5 cities.City# X Y—————————————-1| 2.5 52| 5.1 33| 1 94| 5.4 545| 5.5 2.1 Generate a PHP program that calculates the distance among all cities and display it as a 5 * 5 table. The element at row = i and col = j will show the distance between cities i and j. For example, row 2 and col 3 will show distance between city 2 and city 3.Note: Distance between two cities is defined as Euclidian distance. For example, the distance between city 2 and city 3 will be: D = sqrt ( (x2-x3)^2 + (y2-y3)^2 ) = sqrt ( (5.1-1)^2 + (3-9)^2 ) = 7.267 Part 2 – Central PointLets assume we want to build a central big hospital/medical research in one of these cities and want to find the city that can be the best choice for all the other cities to access it. Given a set of cities, the central city is the city that has the shortest total distance to all other cities. Write a PHP program that finds the central city and its total distance to all other cities for the 5 cities in part 1.Hint: This is not much of additional work (perhaps just another 10 lines of code). You just need to find the total (sum) distance from each city to all other cities and the city with the shortest total distance to all other cities. Please use PHP code and HTML code for these 2 parts. post the result and details on the below. thank you. This class is CSC 680 Data Web-Interface. Engineering & Technology Computer Science Share QuestionEmailCopy link Comments (0)


