Respuesta :

ijeggs

Answer:

import java.util.Scanner;

public class DoWhile {

   public static void main(String[] args) {

       double pointsDistance;

       double Xs, Ys;

   Scanner in = new Scanner(System.in);

       System.out.println("Enter value for x1, x2, y1 and y2");

       int x1 = in.nextInt();

       int x2 = in.nextInt();

       int y1 = in.nextInt();

       int y2 = in.nextInt();

    Xs = Math.pow((x2-x1),2);

    Ys = Math.pow((y2-y1),2);

    pointsDistance = Math.sqrt(Xs+Ys);

       System.out.println("The Distance between the points is "+pointsDistance);

   }

}

Explanation:

The program to determine the distance between the two points is written in Java. Using the scanner we received user input for the values of x1,x2,y1,y2. We created two new variables (Xs and Ys) to hold the values of (x2-x1)2 and (y2-y1)2. and the distance is calculated by finding the square root of the sum of Xs and Ys and printed out. The pow and sqrt methods in java Math class is utilized.

ACCESS MORE