21Numbers to Names

Many programs display information to the end user in one form but use a different form inside the program. For example, you may show the word Blue on the screen, but behind the scenes you’ll have a numerical value for that color or an internal value because you may need to represent the textual description in another language for Spanish-speaking visitors.

Write a program that converts a number from 1 to 12 to the corresponding month. Prompt for a number and display the corresponding calendar month, with 1 being January and 12 being December. For any value outside that range, display an appropriate error message.

Example Output

 
Please enter the number of the month: 3
 
The name of the month is March.

Constraints

  • Use a switch or case statement for this program.

  • Use a single output statement for this program.

Challenges

  • Use a map or dictionary to remove the switch statement from the program.

  • Support multiple languages. Prompt for the language at the beginning of the program.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.40.42