Problem Description The Kuala Lumpur International Airport (KLIA) is growing increasingly prominent as a hub for interna

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Problem Description The Kuala Lumpur International Airport (KLIA) is growing increasingly prominent as a hub for interna

Post by answerhappygod »

Problem Description The Kuala Lumpur International Airport Klia Is Growing Increasingly Prominent As A Hub For Interna 1
Problem Description The Kuala Lumpur International Airport Klia Is Growing Increasingly Prominent As A Hub For Interna 1 (132.33 KiB) Viewed 44 times
Problem Description The Kuala Lumpur International Airport (KLIA) is growing increasingly prominent as a hub for international flights. Most of the transit passengers often visit nine significant places in Kuala Lumpur. All nine attractions are located at various locations from KLIA. Figure 1 shows the P1 to P9 points represent the nine attraction places in Kuala Lumpur, while A point is the KLIA. Every point on the Cartesian plane is referred to as an x-y plane or coordinate, where x and y are integer numbers. P2 (X₂Y₂) P3 (X3.Y3) P1(X1,Y1) P4(X4, Y4) P9 (X9. Y9) A (XA, YA) P5 (Xs. Ys) P6 (X6. Y6) P8(X8, Ys) P7(X7,Y7) Figure 1 Determine the distance between points P1 through P9 with point A, then sort the distances ascendingly.
The formula for distance measurements is derived from the Pythagorean theorem. Where the formula for distance between point p(xp, Yp) and q(xq, Yq) is d = √ ((xp-xq)²+ (Yp-Yq)²) de √(x,-x.) (x,-v₁) * (x1,y1) x2-x1 (x2,y2) y2-yl Used Math.sqrt(M) method to perform the distance calculation. The java.lang.Math.sqrt() returns the square root of M value of type double passed to it as an argument. Example: Double M = 81; System.out.println (Math.sqrt (M)); // prin- value 9.0 Input The first two integers represent the coordinate for point A, followed by nine coordinates for points P1 to P9. Output Display all nine distances in ascending order, followed by two coordinates representing the closest and farthest distances from point A.
Sample Input-Output Input 39 3579-3 104-12801160-911-223 Output 4.0 4.0 6.08 8.54 10.3 13.6 18.25 21.02 The closest point to A: (3,5) (7,9) The farthest point to A: (4,-12)
Solution Given the algorithm for the distance on a Cartesian plane: 1. Define a Cartesian Point class that has; • Three attributes: x-axis, y-axis and DistancefromA 2. Create a List of CartesianPoint. 3. Read the coordinate of point A 4. For each other points a. Read the given point b. Compute the distance between the given point from point A. c. Create an object of CartesianPoint d. Store the point and the distance in the CartesianPoint object. e. Add the Cartesian Point object to the list. Sort the list in ascending order. 6. 7. Display all distances from the list, including the closest and farthest distances from point A.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply