1. 程式人生 > >java練習---5

java練習---5

src ati void ima 程序 imp nbsp n) str

//程序員:羅元昊 2017.9.17

package demo;
import java.util.Scanner;
public class bbb {

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

    System.out.print("輸入x1和y1:");
    double x1 =input.nextDouble();
    double y1 =input.nextDouble();

    System.out.print("輸入x2和y2:");
    double x2 =input.nextDouble();
    double y2 =input.nextDouble();

    double x =Math.pow((x2 - x1),2);
    double y =Math.pow((y2 - y1),2);
    System.out.println("兩個點之間的距離是:"+ Math.pow((x+y),0.5));
  }
}

技術分享

java練習---5