Question: 2 - manhattanDistance ( 1 0 points ) : This method, manhattanDistance, takes four double variables, x 1 , x 2 , y 1 ,
manhattanDistance points:
This method, manhattanDistance, takes four double variables, x x y and y as
inputs. These variables represent the coordinates of two points in a dimensional plane:
and respectively. The method must calculate the Manhattan distance between
these two points and return the result as a double.
The Manhattan distance is calculated by taking the sum of the absolute values of the differences in the coordinates:
Calculate the result and assign it to the variable distance.
Stepbystep workflow:
Find the absolute value of the difference between x and x and store that in a custom variable. For example, if x is and x is your variables value must be
Find the absolute value of the difference between y and y and store that in a custom variable. For example, if y is and y is your variables value must be
Using your two custom variables from the above steps, assign distance to be the sum of your two variables.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
