We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
publicstaticvoidmain(String[]args){/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */Scannerin=newScanner(System.in);StringreturnedDateStr=in.nextLine();StringdueDateStr=in.nextLine();intfine=0;List<Integer>rd=Arrays.asList(returnedDateStr.split("\\s")).stream().map(x->Integer.parseInt(x)).collect(Collectors.toList());List<Integer>d=Arrays.asList(dueDateStr.split("\\s")).stream().map(x->Integer.parseInt(x)).collect(Collectors.toList());if(rd.get(2).equals(d.get(2))&&rd.get(1).equals(d.get(1))&&rd.get(0)>d.get(0)){//check diff between daysfine=15*(rd.get(0)-d.get(0));}elseif(rd.get(2).equals(d.get(2))&&rd.get(1)>d.get(1)){fine=500*(rd.get(1)-d.get(1));}elseif(rd.get(2)>d.get(2)){fine=10000;}System.out.println(fine);}
Day 26: Nested Logic
You are viewing a single comment's thread. Return to all comments →
Java Solution