import java.util.Scanner; class Another { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int testCases = scanner.nextInt(); scanner.nextLine(); int counter = 0; while (testCases-- > 0) { scanner.nextLine(); String current = scanner.nextLine(); String birth = scanner.nextLine(); counter++; System.out.print("Case #"+counter+": "); String cur[] = current.split("/"); String brt[] = birth.split("/"); int currentYear = Integer.parseInt(cur[2]); int currentMonth = Integer.parseInt(cur[1]); int currentDay = Integer.parseInt(cur[0]); int birthYear = Integer.parseInt(brt[2]); int birthMonth = Integer.parseInt(brt[1]); int birthDate = Integer.parseInt(brt[0]); int age = 0, flag = 0; if (currentYear >= birthYear) { if (currentYear == birthYear) { if (currentMonth == birthMonth) { if (currentDay >= birthDate) { System.out.println("0"); flag = 1; } else if (currentDay < birthDate) { System.out.println("Invalid birth date"); flag = 1; } } else if (currentMonth < birthMonth) { System.out.println("Invalid birth date"); flag = 1; } else { System.out.println("0"); flag = 1; } } else { age = currentYear - birthYear; if (currentMonth < birthMonth) { age -= 1; } else if (currentMonth == birthMonth) { if (currentDay < birthDate) { age -= 1; } } } } else { System.out.println("Invalid birth date"); flag = 1; } if (flag == 0) { if (age <= 130) { System.out.println(age); } else { System.out.println("Check birth date"); } } } } }
সোমবার, ১৯ জুন, ২০১৭
11219 How old are you?
এতে সদস্যতা:
মন্তব্যগুলি পোস্ট করুন (Atom)
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন