Java语言程序设计基础篇编程练习题2.15示例代码

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38234015/article/details/88352220
import java.util.Scanner;
public class Test2_15 {
	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 ang y2: ");
		double x2 = input.nextDouble();
		double y2 = input.nextDouble();
		input.close();
		double d1 = Math.pow((x2 - x1),2);
		double d2 = Math.pow((y2 - y1),2);
		double distance = Math.pow(d1 + d2, 0.5);
		System.out.println("The distance between the points is " + distance);
	}
}

猜你喜欢

转载自blog.csdn.net/qq_38234015/article/details/88352220