Coding Exercise: Arrays
Test yourself on the concept of Arrays.
We'll cover the following
Problem
In this exercise, an array stores months that are retrieved later. Write code for a console based “Months App” that meets the requirements listed below.
- If
userResponse
is a number from1
–12
, display the month, like the following:
2 is February
- If
userResponse
containsDisplay All
, display all months from the array on the console, like the following:
January
February
March
April
May
June
July
August
September
October
November
December
- If incorrect information is entered in
userResponse
, display a message saying,
Not a valid input
Sample input
The program accepts one string
parameter, for example:
"8"
Expected output
The finished output of the program should look like the example below:
8 is August
Get hands-on with 1400+ tech skills courses.