Problem Statement
Your friend was born on "leap day" and has always been troubled by the fact that he just turned 24 this year on his 5th birthday. You would like to write him a nice program for his birthday to help him and other leap-day-born people keep track of how many birthdays they've had so far.
You will be given two years as
A leap year is any year that is a multiple of 4, unless it is divisible by 100 and not 400. For example, 1984 was a leap year, but 1900 wasn't, because it was divisible by 100 and not 400. 2000 was a leap year, because it was divisible by both 100 and 400.
Definition
- Class:
- LeapAge
- Method:
- getAge
- Parameters:
- int, int
- Returns:
- int
- Method signature:
- int getAge(int year, int born)
- (be sure your method is public)
Notes
- It is possible that year and born are not actually leap years.
Constraints
- year and born will both be between 1582 and 10000 (1582 is when the Gregorian Calendar started, so there were no leap years before then).
- year will be greater than born.
Examples
2004
1980
Returns: 6
This is the case in the first paragraph of the problem statement.
10000
1582
Returns: 2042
This is about as old as you get in this problem. Note that while the Gregorian Calendar (and therefore, leap years) started in 1582, 1582 wasn't a leap year.
2007
1981
Returns: 6
You really don't know why your lying friend asked you to write this...
1981
1980
Returns: 0
1984
1983
Returns: 1
9700
5795
Returns: 947
5305
2537
Returns: 671
8514
7812
Returns: 170
6228
6134
Returns: 23
8116
3196
Returns: 1193
2273
2020
Returns: 61
2684
2118
Returns: 138
4146
2983
Returns: 282
7717
3156
Returns: 1106
8166
3439
Returns: 1147
9106
5309
Returns: 920
5178
2825
Returns: 570
2788
1935
Returns: 208
9066
8313
Returns: 183
2113
1626
Returns: 118
3524
3067
Returns: 111
3431
2556
Returns: 211
7105
5185
Returns: 465
4642
3967
Returns: 164
3806
3567
Returns: 58
5498
3304
Returns: 532
5043
4907
Returns: 33
4242
1863
Returns: 577
4021
3321
Returns: 170
6001
3237
Returns: 670
7966
5352
Returns: 633
7891
2320
Returns: 1351
3984
3953
Returns: 8
9198
1712
Returns: 1815
2544
2182
Returns: 88
9321
7087
Returns: 542
4963
1676
Returns: 796
4310
2477
Returns: 443
2663
1749
Returns: 221
6569
5936
Returns: 154
1979
1905
Returns: 18
7373
5620
Returns: 425
8230
6619
Returns: 391
7595
3024
Returns: 1108
6037
2415
Returns: 879
2004
1980
Returns: 6
2004
1900
Returns: 26
2400
1590
Returns: 197
2004
1983
Returns: 6
9700
5795
Returns: 947
1981
1980
Returns: 0
2001
1996
Returns: 1