Q:

Java Pogram To Find Distance Between Two Points

belongs to collection: Simple Formula Based Java Programs

0

Java Pogram To Find Distance Between Two Points

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

In this demo I have used NetBeans IDE 8.2 for debugging purpose. But you can use any java programming language compiler as per your availability..

import java.lang.Math.*;
class DistanceBwPoint
{
        public static void main(String arg[])    
        {
        int x1,x2,y1,y2;
        double dis;
        x1=2;y1=2;x2=6;y2=6;
        dis=Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));             
            System.out.println("distancebetween"+"("+x1+","+y1+"),"+"("+x2+","+y2+")===>"+dis);
        }
}

Result:

distancebetween(2,2),(6,6)===>5.656854249492381

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Java Program To Calculate Power Of Number... >>
<< Java Pogram to Calculate Commission Percentage...