WAP to display the distance between 2 points on a line d=√(x²-x¹)³ + (y² – y¹)²

Java program , using scanner class​

WAP to display the distance between 2 points on a line d=√(x²-x¹)³ + (y² – y¹)²

Java program , using scanner class​

About the author
Adalynn

1 thought on “WAP to display the distance between 2 points on a line d=√(x²-x¹)³ + (y² – y¹)² <br /><br />Java program , using scanner class​”

  1. Correct Formula:-

    [tex]\sqrt{ {( {x}_{2} – {x}_{1} )}^{2} +{( {y}_{2} – {y}_{1} )}^{2}} [/tex]

    Required Answer:-

    import java.util.*;

    class Distance {

    public static void main (String ar []){

    Scanner sc=new Scanner (System.in);

    System.out.println(“Enter 1st coordinate”);

    int x1=sc.nextInt();

    int y1=sc.nextInt();

    System.out.println(“Enter 2nd coordinate”);

    int x2=sc.nextInt();

    int y2=sc.nextInt();

    double d=0.0;

    d=Math.sqrt(Math.pow((x2-x1),2)+Math.pow((y2-y1),2));

    System.out.println(“Distance=”+d);

    }

    }

    Reply

Leave a Reply to Emma Cancel reply