1 import java.util.Scanner;
2
3 public class course01 {
4 public static void main(String[] args){
5 System.out.println("Welcome to 'What day is today'");
6
7 Scanner in = new Scanner(System.in);
8
9 System.out.println("Enter year: (e.g, 2012)");
10 int year = in.nextInt();
11
12 System.out.println("Enter month: 1 - 12 : ");
13 int month = in.nextInt();
14
15 System.out.println("Enter the day of the month: 1 - 31 :");
16 int day = in.nextInt();
17
18 // System.out.println(year+ month+day);
19
20 int temp = month;
21 if(temp == 1){
22 month = 13;
23 year -= 1;
24 }
25 else if(temp == 2){
26 month = 14;
27 year -= 1;
28 }
29
30 int k = year % 100;
31 int j = year / 100;
32
33 int h = (day + 26 * (month + 1) / 10 + k + k / 4 + j / 4 + 5 * j) % 7;
34
35 // System.out.println(h);
36
37 switch (h){
38 case 0 :System.out.println("Day of the week is Saturday"); break;
39 case 1 :System.out.println("Day of the week is Sunday"); break;
40 case 2 :System.out.println("Day of the week is Monday"); break;
41 case 3 :System.out.println("Day of the week is Tuesday"); break;
42 case 4 :System.out.println("Day of the week is Wednesday"); break;
43 case 5 :System.out.println("Day of the week is Thursday"); break;
44 case 6 :System.out.println("Day of the week is Friday"); break;
45 }
46 }
47 }
标签:星期,JAVA,int,System,month,今天,year,println,out
来源: https://www.cnblogs.com/yingni/p/11440646.html