TopCoder problem "DayAge" used in SRM 6 (Division I Level One , Division II Level One)



Problem Statement

    
Class Name: DayAge
Method Name: getDaysOld
Parameters: String, String
Returns: int

Implement a class DayAge which contains a method getDaysOld.  The method is
passed, as Strings, someone's birth date and a current date  and returns the
number of days old the person is, as an int.

The input Strings will be of form mm/dd/yyyy.
m, d, and y represent digits (0 through 9).
mm is between 01 and 12, inclusive.
dd is between 01 and 31, inclusive.
yyyy is between 1901 and 2001, inclusive.

Keep in mind:
Thirty days has September, April, June and November; all the rest have
thirty-one, but February twenty-eight alone except in leap year once in four
when February has one day more.
From 1901 to 2001, the leap years are 1904, 1908, ... 2000 (Every 4 years, no
exceptions).
There are 365 days in a non-leap year, 366 in a leap year.

Assume the time the person was born is noon and the time on the current day is
noon.

Here is the method signature:
public int getDaysOld(String birthdate, String currdate);

Notes:
- Both Strings are of the form given above.  TopCoder will prevent improperly
formatted input parameters from reaching your method.
- Both dates exist (no february 30ths or anything) and the birthday is not
after the current day.  TopCoder will check this too.
- If the birth date and current date are the same, the method should return 0.
- The string "Calendar" cannot occur anywhere in your code.

Examples:
If birthdate="10/10/1999" and currdate="10/10/2000", the method returns 366.
If birthdate="02/03/1940" and currdate="12/04/1999", the method returns 21854.
 

Definition

    
Class:DayAge
Method:getDaysOld
Parameters:String, String
Returns:int
Method signature:int getDaysOld(String param0, String param1)
(be sure your method is public)
    

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=77

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=3005&pm=77

Writer:

Unknown

Testers:

Problem categories: