寫了一半看看有沒有錯
public class HelloWorld {
? ? public static void main(String[] args) {
int score = 94;
String sex = "女";
? ? ? ? if(score<80){
? ? ? ? ? ? System.out.println("決賽");
? ? ? ? }else if(sex=="男"){
? ? ? ? ? ? System.out.println("男決賽");
? ? ? ? }
? ? ? ??
? ? ? ??
? ? ? ??
? ? ? ??
2017-06-26
public?class?HelloWorld?{ ????public?static?void?main(String[]?args)?{ int?score?=?94; String?sex?=?"女"; ????????if(score<80){ ????????????if(sex=="女"){ ????????????System.out.println("進入女子組決賽"); ????????????}else{ ????????????????????????System.out.println("進入男子組決賽"); ????????????} ????????}else?{ ?????????????System.out.println("未能進入決賽"); ????????}你的代碼有誤,你分析一下可以得出,你的不能輸出進入某一個類型的決賽。你應該將if判斷的結構邏輯寫完整。
2017-06-26
public?class?HelloWorld?{ ????public?static?void?main(String[]?args)?{ int?score?=?94; String?sex?=?"女"; ????????if(score<80) ????????{ ????????????????if(sex=="女") ????????????????{ ????????????????????System.out.println("進入女子組決賽"); ????????????????} ????????????????else ????????????????{ ????????????????????????System.out.println("進入男子組決賽"); ????????????????} ????????} ????????else? ????????{ ?????????????System.out.println("未能進入決賽"); ????????}你這樣看,看起來是不是就清晰了?不過,你代碼打多了就不用這樣也能看出來了