You are viewing a single comment's thread. Return to all comments →
The Key importance is to check the conditions when the books are returned even before the due date and hence in all those cases setting fine as 0.
public class Solution { static int libraryFine(int d1, int m1, int y1, int d2, int m2, int y2) { int[] month={31,28,31,30,31,30,31,31,30,31,30,31}; int h=0,c=0; if(y1==y2) { if(m1==m2) { if(d1<=d2) { h=0; } else{ h=15*(d1-d2); } } else if(m1<m2) { h=0; } else{ h=500*(m1-m2); } } else if(y1<y2) { h=0; } else{ h=10000; } return h; }
Seems like cookies are disabled on this browser, please enable them to open this website
Library Fine
You are viewing a single comment's thread. Return to all comments →