If statement 我根本无法将第二行(如果小于60行)输出

If statement 我根本无法将第二行(如果小于60行)输出,if-statement,output,If Statement,Output,我有;将运算符从

我有;将运算符从<更改为=80){ System.out.println(“做得很好”); } 如果(分数<80){ System.out.println(“学习更多”); } 如果(分数<60){ System.out.println(“并在办公时间寻求帮助”); } } }

按照您编写的方式,该程序将打印“学习更多”或“并在办公时间寻求帮助”

编写代码的更好方法是:

if (score < 80) {        
    System.out.println("Study more");
}

if (score < 60) {                        
    System.out.println("and go to office hours for help"); 
}

“elseif”中的代码将不会执行,因为“if”语句中的条件已满足所有低于80的值。你可以试试下面的

if ($score <=80 && $score >= 60) {
// Do something
} elseif($Score < 60 ) {
// Do something
}
if($score=60){
//做点什么
}elseif($60分以下){
//做点什么
}

您的
否则,如果您输入的分数低于60Hi,如果
执行情况与预期一样,感谢您的回复。所以,我确实让每一行单独执行,但我现在无法让第2/3行一起输出,如下图所示(两类中都有59行)。我已经更新了我的代码,并附上了上面预期输出的图片。谢谢你。非常感谢你的帮助,我想得太多了!
if (score >= 80) {                           
    System.out.println("Doing well");
} else {
    /* If we've gotten here, we know the score is < 80 */

    System.out.println("Study more");

    if (score < 60) {                        
        System.out.println("and go to office hours for help"); 
    }
}
if ($score <=80 && $score >= 60) {
// Do something
} elseif($Score < 60 ) {
// Do something
}