Determine the Date by the Day Number in Java
The challenge
What date corresponds to the n
th day of the year?
The answer depends on whether the year is a leap year or not.
Write a function that will help you determine the date if you know the number of the day in the year, as well as whether the year is a leap year or not.
The function accepts the day number and a boolean value isLeap
as arguments, and returns the corresponding date of the year as a string "Month, day"
.
Only valid combinations of a day number and isLeap
will be tested.
Examples:
|
|
The solution in Java code
Option 1:
|
|
Option 2:
|
|
Option 3:
Test cases to validate our solution
|
|