-
Notifications
You must be signed in to change notification settings - Fork 5
/
DayOfWeek.java
35 lines (35 loc) · 894 Bytes
/
DayOfWeek.java
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
import java.util.*;
import java.lang.*;
import java.io.*;
class GFG
{
public static void main (String[] args)
{
//code
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0)
{
int d = sc.nextInt();
int m = sc.nextInt();
int y = sc.nextInt();
int q[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };
y -= (m < 3) ? 1 : 0;
int ans = ( y + y/4 - y/100 + y/400 + q[m-1] + d) % 7;
if(ans == 0)
System.out.println("Sunday");
if(ans == 1)
System.out.println("Monday");
if(ans == 2)
System.out.println("Tuesday");
if(ans == 3)
System.out.println("Wednesday");
if(ans == 4)
System.out.println("Thursday");
if(ans == 5)
System.out.println("Friday");
if(ans == 6)
System.out.println("Saturday");
}
}
}