哪里出了問題
public class HelloWorld {
? ? public static void main(String[] args) {
int score = 94;
String sex = "女";
? ? ? ? if(sorce>80){
? ? ? ? ? ? if(sex=="女"){
? ? ? ? ? ? ? ? System.out.println("進入女子組決賽");
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? System.out.println("進入男子組決賽");
? ? ? ? ? ? }
? ? ? ? }else{
? ? ? ? ? ? System.out.println("沒有進入決賽");
? ? ? ? }
? ? ? ??
? ? ? ??
? ? ? ??
? ? ? ??
? ? ? ??
? ? ? ??
? ? ? ??
? ? ? ??
? ? ? ??
}
}
2017-12-07
if score>80 而不是sorce
如果還有別的錯誤的話 我想就是全角半角符的切換問題吧
2017-12-28
字符的判斷應當用.equals()而不能用==,正確代碼如下:
package test1227;
public class test07 {
public static void main(String[] args) {
int score=90;
String sex="女";
if(score>80){
if(sex.equals("女")){
System.out.println("進入女子組決賽");
}else System.out.println("進入男子組決賽");
}else System.out.println("很遺憾你出局");
}
}
2017-12-08
樓上正解.
2017-12-07
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("進入男子組決賽");
? ? ? ? ? ? }
? ? ? ? }
}
}