- import java.util.Scanner;
- public class JPA01 {
-
- public static void main (String args[]){
-
- Scanner scanner = new Scanner(System.in);
-
- System.out.print("請輸入第一組 x 和 y 座標");
- double x1 = scanner.nextDouble();
- double y1 = scanner.nextDouble();
-
- System.out.print("請輸入第二組 x 和 y 座標");
- double x2= scanner.nextDouble();
- double y2= scanner.nextDouble();
-
- float dis = (float)(Math.pow(x2-y2,2)+Math.pow(x1-y1,2));
- dis = (float)Math.sqrt(dis);
-
- System.out.printf("介於 (%.2f , %.2f) 和 (&.2f , &.2f) 之間的距離是 &.2f",x1,x2,y1,y2,dis);
-
-
-
-
- }
- }
複製代碼 |