Question: (URGENT) Java- write a method to obtain the number of the month Write a method called getMonthNumber that takes a String as input containing the
(URGENT) Java- write a method to obtain the number of the month
Write a method called getMonthNumber that takes a String as input containing the name of the month. The method returns the int associated to it (starting from 1 up to 12). If the String does not contain a valid name for a month, then the method should return -1. Note that the method should not be case sensitive.
For example,
getMonthNumber("june") returns 6
getMonthNumber("January") returns 1
getMonthNumber("junes") returns -1
getMonthNumber("JuNe") returns 6
getMonthNumber("cats") returns -1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
