public class If_Demo03 {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
/**
注意点1;if语句最多有1个else语句,俄罗斯人语句在所有的else if语句最后。
2:if语句可以有多个else if语句,它们必须在乐色语句之前。
3;一旦其中一个else if语句检测为true,其它的else if以及else语句都跳过执行
*/
System.out.println("成绩");
int score=scanner.nextInt();
if (score ==100){
System.out.println("A");
}else if (score<100&& score>=90){
System.out.println("B");
}else if (score<90 &&score>=80){
System.out.println("C");
}else if (score<80&&score>=70){
System.out.println("D");
}else {
System.out.println("不合法");
}
}
}
If 多选择结构
最新推荐文章于 2023-01-15 17:06:20 发布