HuberyHu
2018-09-29 20:56
public class HelloWorld {
public static void main(String[] args) {
int score = 94;
String rst;
String sex = "女";
if (score>80)
{if (sex.equals("女")) rst="进入女子组决赛";
else if (sex.equals("男")) rst="进入男子组决赛";
}
else rst="未进入决赛";
System.out.println(rst);
}
}
嗯嗯。
我明白了,不能用else if, 得用else
public class HelloWorld {
public static void main(String[] args) {
int score = 94;
String sex = "女";
String res;
if (score>80)
{if (sex.equals("女")) res="进入女子组决赛";
else res="进入男子组决赛";
}
else res="未进入决赛";
System.out.println(res);
}
}Java入门第一季(IDEA工具)
1168094 学习 · 18754 问题
相似问题