請(qǐng)大佬們幫忙看看哪里錯(cuò)了
public class HelloWorld {
? ? public static void main(String[] args) {
int score = 94;
String sex = "女";
? ? ? ? if(score.equals("score>80")){
? ? ? ? ? ? if(sex.equals("男")){
? ? ? ? ? ? ? ? System.out.println("進(jìn)入決賽");
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? System.oout.println("男子組進(jìn)入決賽");
? ? ? ? ? ? }
? ? ? ? }else{
? ? ? ? ? ? System.out.println("女子組進(jìn)入決賽");
? ? ? ? }else{
? ? ? ? ? ? System.out.println("淘汰");
? ? ? ? }
? ? ? ??
2019-07-16
if(sex.equals("女")){
? ? if(score<94){
? ? ? ? System.out.println("進(jìn)入男子組決賽");
? ? }else{
? ? ? ? System.out.println("進(jìn)入女子組決賽");
? ? }
}else{
? ? System.out.println("進(jìn)入男子組決賽");
}
2019-06-10
等于女那里寫錯(cuò)了 應(yīng)該用equals 不是=
2019-06-05
System.oout.println("男子組進(jìn)入決賽"); 是out,不是oout;
score.equals("score>80"),數(shù)值比較直接用?score>80,不理解為何要用equals;
多重if時(shí),后面兩個(gè)else對(duì)一個(gè)if,不能這么寫。下面是我改的,可以參考下。
public class HelloWorld {
public static void main(String[] args) {
int score = 94;
String sex = "女";
? ? ? ? if(score>80){
? ? ? ? ? ? if(sex.equals("男")){
? ? ? ? ? ? ? ? System.out.println("進(jìn)入決賽");
? ? ? ? ? ? ?System.out.println("男子組進(jìn)入決賽");
? ? ? ? ? ? }
? ? ? ? else? {
? ? ? ? ? ? System.out.println("女子組進(jìn)入決賽");
? ? ? ? }}else{
? ? ? ? ? ? System.out.println("淘汰");
? ? ? ? }}}