if 定义形式
if(布尔运算值){源程序;}
else if(布尔运算值){源程序;}
else if(布尔运算值){源程序;}
else{程序}
package com.scanner.demo;
import java.util.Scanner;
public class IfDemo01 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);//定义扫描仪
System.out.println("请输入成绩:");
int score = sc.nextInt();//接受成绩
if (score>=90&&score<=100){
System.out.println("A级");
}else if (score>=80&&score<90){
System.out.println("B级");
}else if (score>=70&&score<80){
System.out.println("C级");
}else if (score>=60&&score<70){
System.out.println("D级");
}else if (score>=0&&score<60){
System.out.println("不及格");
}else {
System.out.println("成绩不合法");
}
sc.close();//关闭资源,防止程序占用资源
}
}