switch語句輸出百分制的分數段
阿新 • • 發佈:2019-01-08
import java.util.Scanner; public class Grade { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int grade=sc.nextInt(); int a; a=grade/10; switch(a) { case 0: case 1: case 2: case 3: case 4: case 5:System.out.println("d!");break; case 6:System.out.println("c!");break; case 7:System.out.println("b!");break; case 8: if(grade%10<5) {System.out.println("b");break;} else { System.out.println("a");break; } case 9: case 10:System.out.println("a");break; } } }