-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61501ff
commit 199abb6
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* I have a cat and a dog. | ||
I got them at the same time as kitten/puppy. That was humanYears years ago. | ||
Return their respective ages now as [humanYears,catYears,dogYears] | ||
NOTES: | ||
humanYears >= 1 | ||
Cat Years | ||
15 cat years for first year | ||
+9 cat years for second year | ||
+4 cat years for each year after that | ||
Dog Years | ||
15 dog years for first year | ||
+9 dog years for second year | ||
+5 dog years for each year after that */ | ||
|
||
public static int[] humanYearsCatYearsDogYears(final int humanYears) { | ||
int catAge; | ||
int dogAge; | ||
if (humanYears == 1) { | ||
catAge = 15; | ||
dogAge = 15; | ||
} | ||
else if (humanYears == 2) { | ||
catAge = 15 + 9; | ||
dogAge = 15 + 9; | ||
} | ||
else { | ||
catAge = (15 + 9 + (4 * (humanYears - 2))); | ||
dogAge = (15 + 9 + (5 * (humanYears - 2))); | ||
} | ||
return new int[]{humanYears,catAge,dogAge}; | ||
} |