Days In Month

Write a program DaysInMonth.java that asks the user to enter a number for the month (1 = January, 2 = February, and so on) and then prints the number of days for that month. For February, print “28 days”.

Sample interaction:

Enter a month (1-12): 5
31 days

Variation

As part of the assignment, write the int method getDays(int month) that takes a month number as a parameter and returns the number of days in that month. The main() program should use that method in printing out the answer.

Extension

If the user enters 2 for February, ask what year it is and perform calculations to determine whether the number of days that month is 28 or 29.