-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZellersCongruence.java
More file actions
59 lines (40 loc) · 1.09 KB
/
ZellersCongruence.java
File metadata and controls
59 lines (40 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import java.util.Scanner;
public class ZellersCongruence{
public static void main(String[] args){
Scanner zeller = new Scanner(System.in);
System.out.print("Enter month: ");
int month = zeller.nextInt();
System.out.print("Enter year: ");
int year = zeller.nextInt();
System.out.print("Enter days: ");
int day = zeller.nextInt();
int jubilee = 26 * (month + 1) / 10;
int year1 = year % 100;
int century = year / 100;
int year2 = year1 / 4;
int century2 = century / 4;
int century3 = 5 * century;
int daysOfTheWeek = (day + jubilee + year1 + year2 +century2 + century3) % 7;
if(daysOfTheWeek == 0){
System.out.print("Day of the week is Saturday");
}
if(daysOfTheWeek == 1){
System.out.print("Day of the week is Sunday");
}
if(daysOfTheWeek == 2){
System. out.print("Day of the week is Monday");
}
if(daysOfTheWeek == 3){
System.out.print("Day of the week is Tuesday");
}
if(daysOfTheWeek == 4){
System.out.print("Day of the week is Wednesday");
}
if(daysOfTheWeek == 5){
System.out.print("Day of the week is Thursday");
}
if(daysOfTheWeek == 6){
System.out.print("Day of the week is Friday");
}
}
}