HW2.20

时间:2022-10-13 20:36:30

HW2.20

HW2.20

 import java.util.Scanner;

 public class Solution
 {
     public static void main(String[] args)
     {
         Scanner input = new Scanner(System.in);

         System.out.print("Enter x1 and y1: ");
         double x1 = input.nextDouble();
         double y1 = input.nextDouble();

         System.out.print("Enter x2 and y2: ");
         double x2 = input.nextDouble();
         double y2 = input.nextDouble();

         input.close();

         double distanceSquare = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
         double distance = Math.pow(distanceSquare, 0.5);

         System.out.println("The distance of the two points is " + distance);
     }
 }

相关文章