1.

/**
* Angewandte Mathematik, SS11
* Problem: 11219 How old are you?
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2160
*
* @author Weber Christian
* @author Waldleitner Christoph
* @author Marco Wolff
* @version 1.0, 03/05/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.216
*/

import java.io.IOException;
import java.util.Scanner;


public class HowOldAreYou
{
public static void main(String[] args) throws IOException
{
Scanner scan = new Scanner(System.in);
int maxLoop = scan.nextInt();
int dayFirst,monthFirst,yearFirst;
int dayLast,monthLast,yearLast;
int dayDelta,monthDelta,yearDelta;
String dateFirst;
String dateLast;
int loop = 0;

do
{
loop++;
int year = 0;
String blank = scan.nextLine();
while(blank.equals(""))
{
blank = scan.nextLine();
}
dateFirst = blank;
dateLast = scan.nextLine();

dayFirst = Integer.parseInt(dateFirst.split("/")[0]);
monthFirst = Integer.parseInt(dateFirst.split("/")[1]);
yearFirst = Integer.parseInt(dateFirst.split("/")[2]);

dayLast = Integer.parseInt(dateLast.split("/")[0]);
monthLast = Integer.parseInt(dateLast.split("/")[1]);
yearLast = Integer.parseInt(dateLast.split("/")[2]);

dayDelta = dayFirst - dayLast;
monthDelta = monthFirst - monthLast;
yearDelta = yearFirst - yearLast;

if(dayDelta <= 0 && monthDelta <= 0 && yearDelta <= 0)
{
year = -1;
if(dayDelta == 0 && monthDelta == 0 && yearDelta == 0)
{
year =0;
}
}
else
{
if(monthDelta == 0)
{
if(dayDelta >= 0)
{
year = yearDelta;
}
else
{
year = yearDelta -1;
}
}
else if(monthDelta < 0)
{
year = yearDelta -1;
}
else if(monthDelta>0)
{
year = yearDelta;
}
}


if(year >= 0 && year <= 130)
{
System.out.println("Case #"+loop+": " + year);
}
else if(year<0)
{
System.out.println("Case #"+loop+": Invalid birth date");
}
else if(year>130)
{
System.out.println("Case #"+loop+": Check birth date");
}
}while(loop<maxLoop);
}
}

2.

/**
* Angewandte Mathematik, SS11
* Problem: 11219 How old are you?
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=117&page=show_problem&problem=2834
*
* @author Ritter Marius
* @author Wende Tom
* @author Zehentbauer Stefan
* @version 1.0, 10/23/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.184
*/import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
public static void main(String[] args) throws IOException {
BufferedReader scr = new BufferedReader(new InputStreamReader(System.in));
String date1;
String date2;
int calc1;
int calc2;
int result;
int count = Integer.parseInt(scr.readLine());
for (int i = 1; i <= count; i++) {
date1 = scr.readLine();
date1 = scr.readLine();
date2 = scr.readLine();
calc1 = Integer.parseInt(date1.substring(6));
calc2 = Integer.parseInt(date2.substring(6));
result = calc1 - calc2;
if (result >= 0) {
calc1 = Integer.parseInt(date1.substring(3, 5));
calc2 = Integer.parseInt(date2.substring(3, 5));
if (calc1 < calc2)
result = result - 1;
else if (calc1 == calc2) {
calc1 = Integer.parseInt(date1.substring(0, 2));
calc2 = Integer.parseInt(date2.substring(0, 2));
if (calc1 < calc2)
result = result - 1;
}
}
if (result < 0)
System.out.println("Case #" + i + ": Invalid birth date");
else if (result > 130)
System.out.println("Case #" + i + ": Check birth date");
else
System.out.println("Case #" + i + ": " + result);
}
}
}

-----------------------------------------------------------------------------------------------------------------------------


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);
}

}
}
}