-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibraryFine.java
More file actions
33 lines (26 loc) · 882 Bytes
/
LibraryFine.java
File metadata and controls
33 lines (26 loc) · 882 Bytes
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
import java.util.Scanner;
public class LibraryFine {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter number of days late: ");
int daysLate = scanner.nextInt();
double fine;
String message;
if (daysLate <= 7) {
fine = daysLate * 0.5; // 50 paise per day
message = "Fine: Rs. " + fine;
} else if (daysLate <= 14) {
fine = 1; // Re. 1 per day
message = "Fine: Rs. " + fine;
} else {
if (daysLate > 21) {
message = "Membership Cancelled";
} else {
fine = 5 * (daysLate - 14); // Rs. 5 per day after 14 days
message = "Fine: Rs. " + fine;
}
}
System.out.println(message);
scanner.close();
}
}