Task Two Implement the function void find NearestShop(). This function asks the user for the coordinates of shops around

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

Task Two Implement the function void find NearestShop(). This function asks the user for the coordinates of shops around

Post by answerhappygod »

Task Two Implement The Function Void Find Nearestshop This Function Asks The User For The Coordinates Of Shops Around 1
Task Two Implement The Function Void Find Nearestshop This Function Asks The User For The Coordinates Of Shops Around 1 (111.69 KiB) Viewed 42 times
Task Two Implement the function void find NearestShop(). This function asks the user for the coordinates of shops around the store to find the closest shop to restock from. The store is at location: (SHOP LOCATION_X, SHOP_LOCATION_Y) where SHOP_LOCATION_X is the x coordinate of the shop, and SHOP_LOCATION_Y is the y coordinate of the shop. Both values are defined as constants at the top of the program, and you can use them inside this function directly. To find the distance between 2 points (x₁, y₁) and (x2, y2), there are many ways. We know the Euclidean Distance, which is calculated as: √(x₂ - y₂)² + (x₂-x₂)² Page 9 of 15 There is also another way called the Manhattan Distance, which is calculated as: ly₂-y₁l+ 1x₂-x₂l Before you implement find NearestShop, it is recommended that you implement the 2 functions euclideanDistance, manhattan Distance to return the distance between 2 points each depending on its equation above, so you could use them in this task. When findNearestShop starts, it should ask the user to enter a word to decide which distance measure to use (check figure 2): "euclidean" for Euclidean Distance "manhattan" for Manhattan Distance If the user enters any other word, print an error message and ask for the word again. 1 Enter the distance measure you would like to use: Type euclidean for Euclidean distance. Or type manhattan for Manhattan distance. Figure 2 After the user enters the word, it asks the user to enter the number of shops nearby. For each shop nearby, it asks the user to enter the coordinates x y of that shop, then computes the distance of that shop to the store using the selected distance measure. The function should return the distance of the closest shop to the store, which will then be printed inside the mainMenu function as explained in Task 1. HTU. جامعة الحسين التقنية Al Hussain Technical University
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply