JAVA-2-GetDay

 import java.util.*;

 public class Ch0310 {

     public static void main(String[] args) {
         // TODO 自动生成的方法存根
         Scanner in = new Scanner(System.in);
         System.out.println("输入年份:");
         int year = in.nextInt();
         System.out.println("输入月份:");
         int month = in.nextInt();
         System.out.println("输入日期:");
         int day = in.nextInt();

         int a = day;
         for (int i = 0; i < month; i++) {

             switch (i) {
             case 1:
             case 3:
             case 5:
             case 7:
             case 8:
             case 10:
             case 12:
                 a += 31;
                 break;
             case 4:
             case 6:
             case 9:
             case 11:
                 a += 30;
                 break;
             case 2:
                 if (year % 100 != 0 && year % 4 == 0 || year % 400 == 0) {
                     a += 29;
                 } else {
                     a += 28;
                 }
                 break;
             default:
                 break;
             }

         }
         System.out.println(year + "年" + month + "月" + day + "日是这年的第" + a + "天");
         in.close();
     }
 }
上一篇:SS命令和Netstat命令比较


下一篇:Eclipse+ADT+Android SDK 搭建安卓开发环境(版权属于forever-z)