publicclass ComputeWeek {
publicstaticvoidmain(String[] args) {
// TODO Auto-generated method stub
java.util.Scanner input = new java.util.Scanner(System.in);
System.out.print("Enter year: (e.g.,2012): ");
int y = input.nextInt();
System.out.print("Enter month: 1-12: ");
int m = input.nextInt();
System.out.print("Enter the day of the month : 1-31: ");
int q = input.nextInt();
int j = (int)(y /100); //世纪数 int k = y %100; //该世纪的第几年int h = (q + (26*(m+1)/10) + k + (k / 4) + (j / 4) + (5*j))%7;
switch(h) {
case0:System.out.println("Day of the week is Saturday");break;
case1:System.out.println("Day of the week is Sunday");break;
case2:System.out.println("Day of the week is Monday");break;
case3:System.out.println("Day of the week is Tuesday");break;
case4:System.out.println("Day of the week is Wednesday");break;
case5:System.out.println("Day of the week is Thursday");break;
case6:System.out.println("Day of the week is Friday");break;
}
}
}