@@ -0,0 +1,2946 @@
+package algorithms.warmup;%0D%0A%0D%0Aimport java.util.Scanner;%0D%0A%0D%0A/*%0D%0A * Problem Statement: %0D%0A * The Head Librarian at a library wants you to make a program that calculates%0D%0A * the fine for returning the book after the return date. You are given the%0D%0A * actual and the expected return dates. Calculate the fine as follows:%0D%0A * %0D%0A * If the book is returned on or before the expected return date, no fine will%0D%0A * be charged, in other words fine is 0.%0D%0A * %0D%0A * If the book is returned in the same calendar month as the expected return%0D%0A * date, Fine = 15 Hackos  Number of late days%0D%0A * %0D%0A * If the book is not returned in the same calendar month but in the same%0D%0A * calendar year as the expected return date, Fine = 500 Hackos  Number of late%0D%0A * months%0D%0A * %0D%0A * If the book is not returned in the same calendar year, the fine is fixed at%0D%0A * 10000 Hackos.%0D%0A * %0D%0A * Input Format: %0D%0A * You are given the actual and the expected return dates in D M Y format%0D%0A * respectively. There are two lines of input. The first line contains the D M Y%0D%0A * values for the actual return date and the next line contains the D M Y values%0D%0A * for the expected return date.%0D%0A * %0D%0A * Constraints:%0D%0A * 1 %3C= D %3C= 31%0D%0A * 1 %3C= M %3C= 12%0D%0A * 1 %3C= Y %3C= 3000%0D%0A * %0D%0A * Output Format: %0D%0A * Output a single value equal to the fine.%0D%0A * %0D%0A * Sample Input:%0D%0A * 9 6 2015%0D%0A * 6 6 2015%0D%0A * %0D%0A * Sample Output: %0D%0A * 45%0D%0A */%0D%0Apublic class LibraryFine %7B%0D%0A%0D%0A%09public static void main(String%5B%5D args) %7B%0D%0A        Scanner sc = new Scanner(System.in);%0D%0A        %0D%0A        String actualReturnDateString = sc.nextLine();%0D%0A        String expectedReturnDateString = sc.nextLine();%0D%0A        %0D%0A        sc.close();%0D%0A        %0D%0A        String%5B%5D actualReturnDate = actualReturnDateString.split(%22 %22);%0D%0A        String%5B%5D expectedReturnDate = expectedReturnDateString.split(%22 %22);%0D%0A        %0D%0A        int actualReturnYear = Integer.parseInt(actualReturnDate%5B2%5D);%0D%0A        int expectedReturnYear = Integer.parseInt(expectedReturnDate%5B2%5D);%0D%0A        int actualReturnMonth = Integer.parseInt(actualReturnDate%5B1%5D);%0D%0A        int expectedReturnMonth = Integer.parseInt(expectedReturnDate%5B1%5D);%0D%0A        int actualReturnDay = Integer.parseInt(actualReturnDate%5B0%5D);%0D%0A        int expectedReturnDay = Integer.parseInt(expectedReturnDate%5B0%5D);%0D%0A        %0D%0A        int fineAmount;%0D%0A        %0D%0A        if (actualReturnYear %3E expectedReturnYear) %7B%0D%0A            fineAmount = 10000;%0D%0A        %7D else if (actualReturnYear %3C expectedReturnYear) %7B%0D%0A        %09fineAmount = 0;%0D%0A        %7D else if (actualReturnMonth %3E expectedReturnMonth) %7B%0D%0A            fineAmount = 500 * (actualReturnMonth - expectedReturnMonth);%0D%0A        %7D else if (actualReturnMonth %3C expectedReturnMonth) %7B%0D%0A        %09fineAmount = 0;%0D%0A        %7D else if (actualReturnDay %3E expectedReturnDay) %7B%0D%0A            fineAmount = 15 * (actualReturnDay - expectedReturnDay);%0D%0A        %7D else %7B%0D%0A        %09fineAmount = 0;%0D%0A        %7D%0D%0A       %0D%0A        System.out.println(fineAmount);%0D%0A    %7D%0D%0A%7D

Add LibraryFine