Write method Distance to calculate the distance between
two points (x1, y1) and (x2, y2). All numbers and return values should be of type double
Answers
Answered by
0
Answer:
SOLUTION:-
Assume we have two points M and N, with coordinates (x1, y1) and (x2, y2) respectively. Their distance can be represented as MN and it can be calculated as given below formula,
The first point (M):- (x1, y1)
Second point (N):- (x2, y2)
Distance (MN):- √((x2 – x1)2 + (y2 -y1)2)
EXAMPLE:-
M = (4, 8)
N = (12, 14)
Then distance between M and N is, MN = √((12-4)2 + (14-8)2) = √(64 + 36) = √(100) = 10
Similar questions