This repository was archived by the owner on Feb 6, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy path26_Nested_Logic.java
More file actions
48 lines (42 loc) · 1.65 KB
/
Copy path26_Nested_Logic.java
File metadata and controls
48 lines (42 loc) · 1.65 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
38
39
40
41
42
43
44
45
46
47
48
/**
* Your local library needs your help! Given the expected and actual return dates for a library book,
* create a program that calculates the fine (if any). The fee structure is as follows:
*
* If the book is returned on or before the expected return date, no fine will be charged (i.e.: fine = 0).
*
* If the book is returned after the expected return day but still within the same calendar month and year
* as the expected return date, fine = 15 Hackos * (the number of days late).
*
* If the book is returned after the expected return month but still within the same calendar year
* as the expected return date, the fine = 500 Hackos * (the number of months late).
*
* If the book is returned after the calendar year in which it was expected, there is a fixed fine of 10000 Hackos.
*/
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int[] actual = new int[3];
for(int i = 0; i < 3; i++){
actual[i] = in.nextInt();
}
int[] expected = new int[3];
for(int i = 0; i < 3; i++){
expected[i] = in.nextInt();
}
in.close();
int fine = 0;
if(expected[2] == actual[2]){
if(expected[1] < actual[1]){
fine = (actual[1] - expected[1]) * 500;
}
else if((expected[1] == actual[1]) && (expected[0] < actual[0])){
fine = (actual[0] - expected[0]) * 15;
}
} else if(expected[2] < actual[2]){
fine = 10000;
}
System.out.println(fine);
}
}