2012年4月4日 星期三

練習題 2_5:月份英翻中

執行結果,如下。


程式碼,如下。

import java.util.Scanner;

public class EX2_5 {

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);

        System.out.print(" 請輸入月份 》》》》》 ");
        String month = stdIn.next();

        String outStr = "輸入錯誤。";

        if ("1".equals(month)) {
            outStr = "Januery";
        } else if ("2".equals(month)) {
            outStr = "February";
        } else if ("3".equals(month)) {
            outStr = "March";
        } else if ("4".equals(month)) {
            outStr = "April";
        } else if ("5".equals(month)) {
            outStr = "May";
        } else if ("6".equals(month)) {
            outStr = "June";
        } else if ("7".equals(month)) {
            outStr = "July";
        } else if ("8".equals(month)) {
            outStr = "August";
        } else if ("9".equals(month)) {
            outStr = "Stptember";
        } else if ("10".equals(month)) {
            outStr = "October";
        } else if ("11".equals(month)) {
            outStr = "November";
        } else if ("12".equals(month)) {
            outStr = "December";
        }

        System.out.println(" 英文 》》》》》 " + outStr);
    }

}

No Response to "練習題 2_5:月份英翻中"

張貼留言