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


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Need help (Method)

  1. #1
    Junior Member
    Join Date
    Jun 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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. #2
    Member
    Join Date
    Apr 2014
    Posts
    219
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default 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. #3
    Member Ada Lovelace's Avatar
    Join Date
    May 2014
    Location
    South England UK
    Posts
    414
    My Mood
    Angelic
    Thanks
    27
    Thanked 61 Times in 55 Posts

    Default 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.

    Wishes Ada xx
    If to Err is human - then programmers are most human of us all.
    "The Analytical Engine offers a new, a vast, and a powerful language . . .
    for the purposes of mankind
    ."
    Augusta Ada Byron, Lady Lovelace (1851)

Similar Threads

  1. Replies: 1
    Last Post: May 27th, 2014, 07:39 PM
  2. Replies: 2
    Last Post: May 27th, 2014, 12:36 PM
  3. Replies: 6
    Last Post: December 29th, 2013, 03:34 PM
  4. Replies: 1
    Last Post: January 23rd, 2013, 07:29 AM
  5. [SOLVED] How to create a Java generic method, similar to a C++ template method?
    By Sharmeen in forum Object Oriented Programming
    Replies: 3
    Last Post: October 18th, 2012, 02:33 AM