Question: I need to: write a method that takes as parameters x1, y1, x2, and y2 where x1,y1 and x2,y2 are coordinate pairs in a 2-dimensional

I need to:

write a method that takes as parameters x1, y1, x2, and y2 where x1,y1 and x2,y2 are coordinate pairs in a 2-dimensional Cartesian space. This method is to calculate the distance between these two points and return that value.

All these go into a Java program where each is called by a method. Here is a portion of what that program could look like:

public static void main(String[] args){ exercise1(); exercise3(); exercise9();

int x1 = 37; int y1 = -42; int x2 = -5; int y2 = -20;

double distance = findDistance(x1, y1, x2, y2);

System.out.println("Distance between the points is: " + distance);

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!