Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

1. ## Need help (Method)

This is the question
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. Incorporate this method into an application that enables the user to enter the coordinates of the points.

Hints:

• The distance between two points can be calculated by taking the square root of

( x2 - x1 )2 + ( y2 - y1 )2

• Use Math class methods to compute the distance.

• Your output should appear as follows:

Type the end-of-file indicator to terminate

On UNIX/Linux/Mac OS X type <ctrl> d then press Enter

On Windows type <ctrl> z then press Enter

Or Enter X1: 1

Enter Y1: 1

Enter X2: 4

Enter Y2: 5

Distance is 5.000000

Type the end-of-file indicator to terminate

On UNIX/Linux/Mac OS X type <ctrl> d then press Enter

On Windows type <ctrl> z then press Enter

Or Enter X1: ^Z

2. ## Re: Need help (Method)

What have you done to solve this? Post some code and we can help you out but I will not just give you this answer.

3. ## Re: Need help (Method)

Look at the question given and try to solve it on paper first. Modify that into
pceudocode (spelling?) and create a workable algorithm from that.