-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay26.java
More file actions
37 lines (30 loc) · 1.16 KB
/
Day26.java
File metadata and controls
37 lines (30 loc) · 1.16 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
import java.io.*;
import java.util.*;
public class Solution {
public int day;
public int month;
public int year;
public Solution(int day, int month, int year) {
this.day = day;
this.month = month;
this.year = year;
}
public static int calculateFine(Solution dc1, Solution dc2){
int fine = 0;
if(dc1.year > dc2.year)
fine = 10000;
else if(dc1.month > dc2.month && dc1.year == dc2.year)
fine = 500 * Math.abs(dc1.month-dc2.month);
else if(dc1.day > dc2.day && dc1.month == dc2.month && dc1.year == dc2.year)
fine = 15 * Math.abs(dc1.day-dc2.day);
return fine;
}
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
Solution returnedDate = new Solution(sc.nextInt(), sc.nextInt(), sc.nextInt());
Solution dueDate = new Solution(sc.nextInt(), sc.nextInt(), sc.nextInt());
int fine = calculateFine(returnedDate, dueDate);
System.out.println(fine);
}
}