/*
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 发布