/**
* 几何方面:点是否在矩形内?
* 提示用户输入一个点 (x, y):
* 检查这个点是否在以原点 (0, 0)为中心、宽为10、高为5的矩形内。
*/
package Test;
import java.util.Scanner;
public class T323Scanner {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter a point weith two coordinates: ");
double x = input.nextInt();
double y = input.nextInt();
System.out.println(Math.abs(x) <= 5 && Math.abs(y) <= 2.5
? "Point (" + x + ", " + y + ") is in the rectangle!"
: "Point (" + x + ", " + y + ") is not in the rectangle!");
}
}
第3章:几何方面:点是否在矩形内?
最新推荐文章于 2023-09-11 00:55:40 发布