Question: In Java Method #1: Write a method getNumber Days, that receives an int that is a month number (1-12) and returns the number of days
In Java
Method #1: Write a method getNumber Days, that receives an int that is a month number (1-12) and returns the number of days in that month. For February, always return 28 as you won't have the year. If the month received is out of range, return O. Note: you should not have 12 separate if statements, rather efficiently combine statements either using a switch statement in Java or using relational operations (&& 1) to determine the proper value to return. method signature: public static int getNumber Days(int month) Examples: int days = getNumber Days(12); // should return 31 days = getNumber Days(2); // should return 28 days = getNumber Days(14); // should return 0; days = getNumber Days(6); // should return 30
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
