0
点赞
收藏
分享

微信扫一扫

提示用户输入一个点(x, y),检查这个点是否在以原点(0, 0)为圆心,半径为10的圆内。

全栈顾问 2022-03-13 阅读 82
几何学

提示用户输入一个点(x, y),检查这个点是否在以原点(0, 0)为圆心,半径为10的圆内。

import java.util.*;
public class circle {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.print("Enter a point with two coordinates: ");
		double x = input.nextDouble();
		double y = input.nextDouble();
		double lenth = Math.sqrt(x * x + y * y);
		if(lenth > 10) {
			System.out.printf("Point (%.1f, %.1f) is not in the circle",x,y);
		}
		else
			System.out.printf("Point (%.1f, %.1f) is in the circle",x,y);
	}

}
举报

相关推荐

输入一个数 判断是否为素数

0 条评论