Write a function. It will return the name of a month of the year, given the month number, according to the table below. Make sure you do not put any input or output statements in the function; the month number will be passed in and the string containing the name will be returned.
Number | Month |
---|---|
1 | January |
2 | February |
3 | March |
4 | April |
5 | May |
6 | June |
7 | July |
8 | August |
9 | September |
10 | October |
11 | November |
12 | December |
anything else | error |
The function must be called monthName()
,
and must have one parameter (an integer), and return a
String
.
Month 1: January Month 2: February Month 3: March Month 4: April Month 5: May Month 6: June Month 7: July Month 8: August Month 9: September Month 10: October Month 11: November Month 12: December Month 43: error Month 17: error Month -1: error Month 28: error
©2003–2016 Graham Mitchell
This assignment is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.