- import java.util.Scanner;
- public class ch16 //類別
- {
- public static void main(String args[]) //主方法
- {
- Scanner s=new Scanner(System.in);
- int score, level;
- System.out.print("請輸入你的成績: ");
- score=s.nextInt();
- level=score/10;
- switch(level)
- {
- case 10:
- System.out.println("太神了!");
- break;
- case 6: case 7: case 8: case 9:
- System.out.println("及格了!");
- break;
- case 0: case 1: case 2: case 3: case 4: case 5:
- System.out.println("不及格!");
- break;
- default:
- System.out.println("輸入錯誤!");
- }
- }
- }
複製代碼 |