Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit d3a9272

Browse files
authored
Add files via upload
1 parent d9be812 commit d3a9272

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

BlueBook/BlueBookDays.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import java.io.BufferedReader;
2+
import java.io.IOException;
3+
import java.io.InputStreamReader;
4+
5+
public class BlueBookDays {
6+
7+
public static boolean checkLeapYear(int year) {
8+
if (year % 4 == 0) {
9+
if (year % 100 == 0) {
10+
if (year % 400 == 0) {
11+
return true;
12+
} else {
13+
return false;
14+
}
15+
} else {
16+
return true;
17+
}
18+
} else {
19+
return false;
20+
}
21+
}
22+
23+
public static void main(String[] args) throws IOException {
24+
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
25+
26+
int testCases = Integer.parseInt(in.readLine());
27+
28+
int[] dayArray = new int[] {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
29+
30+
String[] input;
31+
int year, month, day;
32+
boolean isLeapYear;
33+
int dayCounter;
34+
35+
for (int i = 0; i < testCases; i++) {
36+
input = in.readLine().split(" ");
37+
year = Integer.parseInt(input[0]);
38+
month = Integer.parseInt(input[1]);
39+
day = Integer.parseInt(input[2]);
40+
isLeapYear = checkLeapYear(year);
41+
dayCounter = 0;
42+
43+
for (int j = 0; j < month - 1; j++) {
44+
if (j == 1 && isLeapYear) {
45+
dayCounter += 29;
46+
} else {
47+
dayCounter += dayArray[j];
48+
}
49+
}
50+
51+
dayCounter += day;
52+
System.out.println(dayCounter);
53+
}
54+
}
55+
56+
}

0 commit comments

Comments
 (0)