- KUZOKU85
- |
- Noble Legendary Member
"Your eyes are full of hate, forty-one. That's good. Hate keeps a man alive. It gives him strength"
Write a Java method that takes three integer values (a month, a day, and a year) as arguments and
returns the number of that day in the year (an integer between
1 and 365, or 366 for leap years).
Your method should have the following header:
public static int dayNum (int month, int day, int year)
To calculate the day number for a given date, use the following formula:
a. dayNum = 31 x (month - 1) + day
b. If the month is after February (2), then subtract (4 x month + 23)/10 from dayNum.
c. If the year is a leap year and the date is after February 29, add 1 to dayNum.