【发布时间】:2023-03-09 15:05:02
【问题描述】:
我想在 Eclipse 中用 Java 编写一个程序,告诉我是否可以制作三角形。这是我的代码:
import java.io.IOException;
public class haromszog {
public static void main(String[] args) throws IOException {
int a;
int b;
int c;
System.out.print("Please insert the 'a' side of the triangle:");
a = System.in.read();
System.out.print("Please insert the 'b' side of the triangle:");
b = System.in.read();
System.out.print("Please insert the 'c' side of the triangle:");
c = System.in.read();
if ((a+b)>c)
{
if ((a+c)>b)
{
if ((b+c)>a)
{System.out.print("You can make this triangle");
}
else
System.out.print("You can't make this triangle");
}
}
}
}
Eclipse,可以运行它,但它写道:
请插入三角形的'a'边:(例如我写:)5
请插入三角形的'b'边:
请插入三角形的“c”边:
你不能做这个三角形
而且我不能在 b 和 c 端写任何东西。这有什么问题?
【问题讨论】: