File tree 1 file changed +75
-0
lines changed 1 file changed +75
-0
lines changed Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ public String dayOfTheWeek(int day, int month, int year) {
3
+ int i = 5;
4
+ int actualDay = 1;
5
+ int actualMonth = 1;
6
+ int actualYear = 1971;
7
+ int count = 3;
8
+ while(true){
9
+ if(actualDay == day){
10
+ if(actualMonth == month){
11
+ if(actualYear == year){
12
+ switch(i){
13
+ case 1:
14
+ return "Monday";
15
+ case 2:
16
+ return "Tuesday";
17
+ case 3:
18
+ return"Wednesday";
19
+ case 4:
20
+ return "Thursday";
21
+ case 5:
22
+ return"Friday";
23
+ case 6:
24
+ return"Saturday";
25
+ case 7:
26
+ return"Sunday";
27
+ }
28
+ }
29
+ }
30
+ }
31
+
32
+ actualDay++;
33
+ i++;
34
+ if(i>7){
35
+ i=1;
36
+ }
37
+
38
+ if(actualMonth == 1 || actualMonth==3 || actualMonth == 5 || actualMonth == 7 || actualMonth == 8 || actualMonth == 10 || actualMonth == 12){
39
+ if(actualDay>31){
40
+ actualDay = 1;
41
+ actualMonth++;
42
+ }
43
+ }
44
+ else if(actualMonth == 2){
45
+ if(count%4 == 0){
46
+ if(actualDay >29){
47
+ actualDay = 1;
48
+ actualMonth ++;
49
+ }
50
+ }
51
+ else{
52
+ if(actualDay>28){
53
+ actualDay = 1;
54
+ actualMonth++;
55
+ }
56
+
57
+ }
58
+
59
+ }
60
+ else{
61
+ if(actualDay>30){
62
+ actualDay=1;
63
+ actualMonth++;
64
+ }
65
+ }
66
+
67
+ if(actualMonth>12){
68
+ actualMonth=1;
69
+ actualYear++;
70
+ count++;
71
+ }
72
+
73
+ }
74
+ }
75
+ }
You can’t perform that action at this time.
0 commit comments