/*
Enter a point with two coordinates: 2 7
Point (2.0, 7.0) is not in the rectangle.
Enter a point with two coordinates: 2 2
Point (2.0, 2.0) is in the rectangle.
*/
import java.util.Scanner;
public class PointInARectagle {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double x1 = 10 / 2, y1 = 5 / 2;
System.out.print("Enter a point with two coordinates: ");
double x2 = input.nextDouble();
double y2 = input.nextDouble();
if (x2 <= x1 && y2 <= y1)
System.out.println("Point (" + x2 + ", " + y2 + ")" + " is in the rectangle.");
else
System.out.println("Point (" + x2 + ", " + y2 + ")" + " is not in the rectangle.");
}
}
Introduction to Java Programming编程题3.22<判断点是否在矩形内>
最新推荐文章于 2023-04-19 22:36:28 发布
本文介绍了一个简单的Java程序,用于判断一个二维坐标点是否位于指定的矩形区域内。通过用户输入坐标值,程序能够即时反馈该点是否落在定义好的矩形内。
1821

被折叠的 条评论
为什么被折叠?



