注册 登录
编程论坛 J2EE论坛

新手请教个问题,求指教

通天塔 发布于 2012-06-11 16:44, 483 次点击
package cho4;

import

public class App4_4 {

    /**
     * @param args输入一个月份
     *            ,输出该月的天数
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        int month, days;
        System.out.println("请输入月份");
        month = (int) System.in.read();
        switch (month) {
        case (2):days = 28;    break;
        case (4):    ;
        case (6):;
        case (9):;
        case(11):;days = 30;break;
        default:
            days = 31;
        }
        System.out.println(month + "月有" + days + "天");

    }

}
在eclipse下输入5,输出53月有31天。为什么多了个3,我试了其他的数字,也有相同的情况出现。
只有本站会员才能查看附件,请 登录
0 回复
1