Month Name

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.

Files Needed

NumberMonth
1January
2February
3March
4April
5May
6June
7July
8August
9September
10October
11November
12December
anything elseerror

The function must be called monthName(), and must have one parameter (an integer), and return a String.

What You Should See

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

Frequently-Asked Questions

I don't know what to do.
Did you do the assignment called Weekday Name? It is very similar to this one.



©2003–2016 Graham Mitchell

This assignment is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.
Creative Commons License