假设将一个直角三角形放置在一个平面上,如下所示。直角点放置在(0, 0)处,另外两个点放置在(200, 0)和(0, 100)处。编写一个程序,提示用户输入带有 x 和 y 坐标的点,并确定该点是否在三角形内部。
`String xInput, yInput;
double x, y;
xInput = JOptionPane.showInputDialog("Enter the x-coordinate of the point");
yInput = JOptionPane.showInputDialog("Enter the y-coordinate of the point");
x = Double.parseDouble(xInput);
y = Double.parseDouble(yInput);
if (x <= 200 && x >= 0 && y <= 100 && y >= 0) {
if (y = roundup(x/2))
System.out.print("The point is in the the triangle");
else
System.out.print("The point isn't in the triangle");
}else
System.out.print("The point isn't in the triangle");`
The output is an error in the second if saying that a double can't be a boolean
阿晨1998
慕慕森
相关分类