/**
 *  需求:利用Scanner,调用Math
 *  思路:利用公式,调用Math.PI
 *   
 *  步骤:略
 */

import java.util.Scanner;
public class Demo_1{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("Enter x1 and y1: ");
        System.out.print("Enter x2 and y2: ");
        double b=input.nextDouble();
        double d=input.nextDouble();
        double a=input.nextDouble();
        double c=input.nextDouble();        
        double  y= (b-a)*(b-a)+(d-c)*(d-c);
        double distance = Math.pow(y, 0.5);//power 求开平方(0.5)
        System.out.print("The distance the two points is " + distance);
    }
}

 

 

(几何:两点间的距离)编写程序,提示用户输入两个点(x1,y1),(x2,y2),然后显示两点间的距离,利用公式,提示:math.pow(a,0.5)=根号啊。

相关文章:

  • 2021-09-15
  • 2022-02-12
  • 2022-01-23
  • 2021-04-07
  • 2022-01-01
  • 2021-12-02
  • 2021-06-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-24
  • 2021-07-20
  • 2021-05-07
  • 2021-08-07
相关资源
相似解决方案