-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day_26_Solution.java
39 lines (33 loc) · 1.26 KB
/
Day_26_Solution.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
36
37
38
39
/**
* Title : Day_26_Solution.java
* Author : Tridib Samanta
* Created : 22-01-2020
* Link : https://www.hackerrank.com/challenges/30-nested-logic/problem
**/
import java.util.Scanner;
import java.time.LocalDate;
public class Day_26_Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
LocalDate returnDate = readDate(scan);
LocalDate expectDate = readDate(scan);
scan.close();
int fine;
if (returnDate.isEqual(expectDate) || returnDate.isBefore(expectDate)) {
fine = 0;
} else if (returnDate.getMonth() == expectDate.getMonth() && returnDate.getYear() == expectDate.getYear()) {
fine = 15 * (returnDate.getDayOfMonth() - expectDate.getDayOfMonth());
} else if (returnDate.getYear() == expectDate.getYear()) {
fine = 500 * (returnDate.getMonthValue() - expectDate.getMonthValue());
} else {
fine = 10000;
}
System.out.println(fine);
}
private static LocalDate readDate(Scanner scan) {
int day = scan.nextInt();
int month = scan.nextInt();
int year = scan.nextInt();
return LocalDate.of(year, month, day);
}
}