close

import java.util.*;
public class averg
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int math_score, english_score, chinese_score;
        double averg;
        System.out.printf("請輸入數學成績: ");
        math_score = sc.nextInt();
        System.out.printf("請輸入英文成績: ");
        english_score = sc.nextInt();
        System.out.printf("請輸入國文成績: ");
        chinese_score = sc.nextInt();
        averg = ( math_score + english_score +chinese_score ) / 3;
        System.out.printf("平均: %2f\n評等: ",averg);
        switch( (int)averg / 10 )  //平均除以10可以得到1~10
          {
            case 10:  //100分的情況
              System.out.printf("A\n ");
              break;
            case 9:  //90~99的情況
              System.out.printf("A\n ");
              break;
            case 8:  //80~89的情況
              System.out.printf("B\n ");
              break;
            case 7:  //70~79的情況
              System.out.printf("C\n ");
              break;
            case 6:  //60~69的情況
              System.out.printf("D\n ");
              break;
            default:  //低於60的情況
              System.out.printf("E\n ");
          } 
    }
}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Icen Zhong 的頭像
    Icen Zhong

    無止盡的Coding地獄

    Icen Zhong 發表在 痞客邦 留言(0) 人氣()