Counting number of days in a given month of a year
Java Program to find number of days in a given month of a year
Number of days in a month can vary depending on a year that is leap year or not .Suppose a year is leap year then February month will consist of 29 days .Suppose a year is not leap year then February month will consist of 28 days .Months like January, march, may , July , august ,October ,December consist of 31 days Irrespective of leap year or not. Months like April ,June ,September , November consist of 30 days irrespective of leap year or not .
- Take user inputs like month and year.
- Check if the given month is February.
- If True Check if the year is a year leap or not.
- If year is a leap year Print 29 Days, Else Print 28 Days.
- If Condition in Step 3 is False Check the month.
- Print the number of days assigned to specific Month.
Code in Java:
enter the month and year
Number of days is 31