返回列表 發帖
  1. import java.util.Scanner;
  2. public class Ch01
  3. {

  4.         public static void main(String[] args)
  5.         {
  6.                 while(true)
  7.                 {       
  8.                     Scanner s=new Scanner(System.in);
  9.                     float score;
  10.                     String str;
  11.                     System.out.print("請輸入你的成績: ");
  12.                     score=s.nextfloat();
  13.                     if(score>=90 && score<100)
  14.                             str="優";
  15.                     else if(score>=80 && score<90)
  16.                             str="甲";
  17.                     else if(score>=70 && score<80)
  18.                             str="乙";
  19.                     else if(score>=60 && score<70)
  20.                             str="丙";
  21.                     else if(score>=0 && score<60)
  22.                             str="丁";
  23.                     else
  24.                             str="輸入錯誤!";
  25.                     System.out.println(str);
  26.                            


  27.                 }
  28.         }

  29. }
複製代碼

TOP

返回列表