问题描述
不了解为什么它无法正确读取
r
解决方法
您正在尝试将s
用作Scanner
,int
和String
。
这是需要调整的部分:
s = s.nextInt();
s = i==i?light:heavy;
i==i
也没有多大意义。这永远是真的。我猜你是说(whatever variable s.nextInt() will be assigned to)==i
Scanner s = new Scanner(System.in).useDelimiter("\r?\n");
System.out.println("How much do you weigh? 100 or 200 ?");
int a = s.nextInt();
String light;
String heavy;
light = (" You are light");
heavy = ("You are heavy");
String result = (a == 100) ? light : (a == 200) ? heavy : "not correct answer";
System.out.println(result);