1./**
 *
 * Problem #11219 - How Old are You?
 *
 *
 * @author Mariya Vlaseva
 *
 * Status : Accepted
 * Runtime: 0.180
 */


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {
   
    private static final DateFormat DATEFORMATER = new SimpleDateFormat("dd/MM/yyyy");
   
    public static void main(String... args)throws IOException, ParseException {
        BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
        String line = console.readLine();
        int cycles = Integer.parseInt(line);
       
        for(int i = 0; line != null && i < cycles; i++) {
            line = console.readLine(); // dummy read, line is empty
            line = console.readLine(); // read current date
            Date currentDate = DATEFORMATER.parse(line);
           
            line = console.readLine(); // read birthdate
            Date birthDate = DATEFORMATER.parse(line);
           
            Calendar current = Calendar.getInstance();
            current.setTime(currentDate);
            Calendar birth = Calendar.getInstance();
            birth.setTime(birthDate);
           
            int age = current.get(Calendar.YEAR) -  birth.get(Calendar.YEAR);
            if (current.get(Calendar.MONTH) < birth.get(Calendar.MONTH) ||
                    (current.get(Calendar.MONTH) == birth.get(Calendar.MONTH) && current.get(Calendar.DATE) < birth.get(Calendar.DATE))) {
                age--;
            }
           
            if(current.before(birth)) {
                System.out.println("Case #" + (i + 1) + ": Invalid birth date");
            } else if (age > 130) {
                System.out.println("Case #" + (i + 1) + ": Check birth date");
            } else {
                System.out.println("Case #" + (i + 1) + ": " + age);
            }
        }
    }
}




2.


/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 11219 How old are you?
*
* @author Robert Reichart
*
* Status : Accepted
* Runtime: 0.176
*/

import java.io.*;
import java.util.*;

class Main{
public static void main(String... args)throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int cases = Integer.parseInt(in.readLine());

for (int o = 0; o<cases;o++){
in.readLine();

String line=in.readLine();
String[] strdates1=line.split("/");
line=in.readLine();
String[] strdates2=line.split("/");

int[] intvalues1=new int[3];
int[] intvalues2=new int[3];
for (int i=0;i<3;i++){
intvalues1[i]=Integer.parseInt(strdates1[i]);
intvalues2[i]=Integer.parseInt(strdates2[i]);
}

GregorianCalendar current = new GregorianCalendar();
int cdate = intvalues1[0];
int cmonth = intvalues1[1];
int cyear = intvalues1[2];
int bdate = intvalues2[0];
int bmonth = intvalues2[1];
int byear = intvalues2[2];

int age = cyear - byear;
if (cmonth < bmonth || (cmonth == bmonth && cdate < bdate)){ age = age - 1;}
if (age<0){
System.out.println("Case #" + (o+1) + ": Invalid birth date");
}else if(age>130){
System.out.println("Case #" + (o+1) + ": Check birth date");
}else{
System.out.println("Case #" + (o+1) + ": " + age);
}

}
}
}