每個(gè)年齡段的判斷應(yīng)該是>=吧?
public?class?HelloWorld?{ ????public?static?void?main(String[]?args)?{ int?age=25; if(age>60){ ????System.out.println("老年"); } else?if(age>=40){ ????System.out.println("中年"); } else?if(age>=18){ ????System.out.println("少年"); } else{ ????System.out.println("童年"); } } }
應(yīng)該像這樣寫(xiě)吧?
2024-07-15
如果我輸入-10呢??