Pretty easy really - the only month that has days that will change from year to year would be February. So you test on the month entered and if it is 1, 3,5,7,8,10 or 12 then 31 days else if it is 2 then check for leap year and if leap year days = 29 else days = 28 (end that if) else days are going to be 30. That's the logic and it's been way to long for me to attempt to write out the java code but follow the above logic and you have your answer.
No comments:
Post a Comment