返回列表 發帖
  1. import java.io.Console;
  2. public class ch13
  3. {
  4.     public static void main(String args[])
  5.     {
  6.          Console c=System.console();
  7.          String str;
  8.          int x,y;
  9.          System.out.print("請輸入你的分數: ");
  10.          x=Integer.parseInt(c.readLine());
  11.          y=x/10;
  12.          switch(y)
  13.          {
  14.          case 10:
  15.          case 9:
  16.              str="優";
  17.              break;
  18.          case 8:
  19.               str="甲";
  20.               break;
  21.          case 7:
  22.               str="乙";
  23.               break;
  24.          case 6:
  25.          str="丙";
  26.          break;
  27.          case 5:
  28.          case 4:
  29.          case 3:
  30.          case 2:
  31.          case 1:
  32.          str="丁";
  33.          break;
  34.          default:
  35.          str="輸入錯誤";
  36.          }
  37.          System.out.print(str);
  38.     }
  39. }
複製代碼

TOP

返回列表