1 import java.util.Scanner; 2 3 public class Solution 4 { 5 public static void main(String[] args) 6 { 7 Scanner input = new Scanner(System.in); 8 9 System.out.print("Enter the year: "); 10 int year = input.nextInt(); 11 System.out.print("Enter the weekday: "); 12 int weekDay = input.nextInt(); 13 14 input.close(); 15 16 String[] monthString = {"January", "February", "March", "April", "May", "June", 17 "July", "August", "September", "October", "November", "December"}; 18 19 int[] dayOfMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 20 21 String[] dayOfWeek = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; 22 23 if((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) 24 dayOfMonth[1]++; 25 26 for(int i = 0; i < 12; i++) 27 { 28 System.out.println(monthString[i] + " 1, " + year + " is " + dayOfWeek[weekDay]); 29 weekDay = (weekDay + dayOfMonth[i]) % 7; 30 } 31 } 32 }
时间: 2024-10-13 06:45:51