Results 1 to 2 of 2
  1. #1
    saudmalibari is offline Member
    Join Date
    Oct 2014
    Rep Power

    Default help at netbeans

    int x1= 7;
    int y1= 4;
    int x2= 1;
    int y2= 6;

    double D= Math.sqrt(Math.pow(x1-x2)+ Math.pow(y1-y2));


    the under line is an error i'm new at netbeans can you help me fix it please.
    i'm trying to calculate the distance between the two pint (x1,y1) (x2,y2)

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default Re: help at netbeans

    The problem is that you are not using Math.pow() correctly. It takes two arguments.
    But since the distance formula is the same as calculating the hypotenuse of a right triangle, you could also use
    Math.hypot(). Check the API for details.

    NB. This is a Java issue, not a NetBeans issue.

    Last edited by jim829; 10-08-2014 at 04:10 PM.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Replies: 16
    Last Post: 07-02-2014, 01:02 PM
  2. Need help with NetBeans
    By coderX in forum NetBeans
    Replies: 2
    Last Post: 11-07-2012, 01:55 PM
  3. Netbeans Help
    By MuslimCoder in forum New To Java
    Replies: 1
    Last Post: 11-07-2009, 02:23 AM
  4. Using SGT API in netbeans
    By Manfizy in forum New To Java
    Replies: 1
    Last Post: 02-13-2009, 10:20 AM
  5. NetBeans 5.5
    By Ry4n in forum NetBeans
    Replies: 3
    Last Post: 01-26-2008, 06:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts