import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String grade =scanner.next(); //write your code here...... switch(grade){ case "A": System.out.println("优秀");break; case "B": System.out.println("良好");break; case "C": System.out.println("及格");break; case "D": System.out.println("不及格");break; default: System.out.println("未知等级"); } /*if(grade=="A") System.out.println("优秀"); else if(grade=="B") System.out.println("良好"); else if(grade=="C") System.out.println("及格"); else if(grade=="D") System.out.println("不及格"); else System.out.println("未知等级"); */ } }
case分支语句,grade是string类型~case ""