123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import java.util.*;
- class TestSwitch05
- {
- public static void main(String[] args)
- {
-
-
- Scanner sc = new Scanner(System.in);
-
- System.out.println("输入年份");
-
- int year = sc.nextInt();
- System.out.println("输入月份");
-
- int month = sc.nextInt();
- System.out.println("输入天数");
-
- int day = sc.nextInt();
-
- int days = 0;
- if(year > 0){
- if(month >=1 && month <= 12){
-
- switch (month){
- case 12:
- days += 30;
- case 11:
- days += 31;
- case 10:
- days += 30;
- case 9:
- days += 31;
- case 8:
- days += 31;
- case 7:
- days += 30;
- case 6:
- days += 31;
- case 5:
- days += 30;
- case 4:
- days += 31;
- case 3:
- days += 28;
-
- if( year % 4 == 0 && year %100 != 0 || year % 400 ==0 ){
- days++;
- }
- case 2:
- days += 31;
- case 1:
- days += day;
-
- }
- System.out.println("2023年的"+month+"和"+day+"是第:"+days);
- }
- }
- }
- }
|