In this HackerRank Day 26: Nested Logic problem solution 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 x (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 x (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.

## Problem solution in Python programming.

#!/bin/python3

import sys

d1,m1,y1 = input().strip().split(' ')
d1,m1,y1 = [int(d1),int(m1),int(y1)]
d2,m2,y2 = input().strip().split(' ')
d2,m2,y2 = [int(d2),int(m2),int(y2)]
if y1-y2>0:
print ("10000")
elif y2-y1>0:
print ("0")
elif m1-m2>0:
print (str (500*(m1-m2)))
elif m2-m1>0:
print ("0")
elif d1-d2>0:
print (str (15*(d1-d2)))
else:
print ("0")

### Problem solution in Java programming.

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

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 scanner = new Scanner(System.in);
int d2 = scanner.nextInt();
int m2 = scanner.nextInt();
int y2 = scanner.nextInt();
int d1 = scanner.nextInt();
int m1 = scanner.nextInt();
int y1 = scanner.nextInt();

int fine = 0;

if (y2<y1) {
fine = 0;
}
else if (y2>y1) {
fine = 10000;
}
else if (y2==y1) {
if (m2<m1) {
fine =0;
}
else if (m2>m1) {
fine = 500 * (m2 - m1);
}
else if (m2==m1) {
if (d2<=d1) {
fine = 0;
}
else {
fine = 15 * (d2 - d1);
}
}
}

System.out.println(fine);
}
}

### Problem solution in C++ programming.

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
int Da, Ma, Ya, De, Me, Ye; cin >> Da >> Ma >> Ya >> De >> Me >> Ye;
if(Ya > Ye) {
cout << 10000;
return 0;
}
if(Ma > Me && Ya >= Ye) {
cout << 500 * (Ma - Me);
return 0;
}
if(Da > De && Ya >= Ye && Ma >= Me) {
cout << 15 * (Da - De);
return 0;
}
cout << 0;
return 0;
}

### Problem solution in C programming.

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {
int m, d, y;
int mm, dd, yy;
scanf("%d %d %d", &d, &m, &y);
scanf("%d %d %d", &dd, &mm, &yy);

if (y < yy)
printf("0\n");
else if (y > yy)
printf("10000\n");
else if (m < mm)
printf("0\n");
else if (m > mm)
printf("%d\n", (m - mm) * 500);
else if (d <= dd)
printf("0\n");
else
printf("%d\n", (d - dd) * 15);
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
return 0;
}

### Problem solution in Java programming.

function processData(input) {
var a = input.split('\n');
var dateR = a[0].split(' ').map(x => Number(x));
var dateE = a[1].split(' ').map(x => Number(x));

var dayR = dateR[0];
var monthR = dateR[1];
var yearR = dateR[2];

var dayE = dateE[0];
var monthE = dateE[1];
var yearE = dateE[2];

if(yearR <= yearE){
if(yearR < yearE || monthR < monthE || (monthR == monthE && dayR <= dayE)){
console.log(0);
} else if(monthR == monthE){
console.log(15 * (dayR - dayE));
} else {
console.log(500 * (monthR - monthE));
}
} else {
console.log(10000);
}
}

process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
_input += input;
});

process.stdin.on("end", function () {
processData(_input);
});