- import java.io.Console;
- public class ch13
- {
- public static void main(String args[])
- {
- Console c=System.console();
- int x,y;
- System.out.print("請輸入成績: ");
- x=Integer.parseInt(c.readLine());
- System.out.println("您剛輸入的成績為"+x);
- y=x/10;
- switch(y)
- {
- case 10:
- case 9:
- System.out.println("優");
- break;
- case 8:
- System.out.println("甲");
- break;
- case 7:
- System.out.println("乙");
- break;
- case 6:
- System.out.println("丙");
- break;
- case 5:
- case 4:
- case 3:
- case 2:
- case 1:
- case 0:
- System.out.println("丁");
- break;
- default:
- System.out.println("輸入錯誤");
- }
- }
- }
複製代碼 |