1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- 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);
- }
- }
- }
- }
|