Ask the user to enter the month of the year (number 1 through 12): “Enter the month of the year - number 1 to 12”b. Get the month using a Scannerc. checks for invalid input (i.e. numbers that are not 1 – 12) and terminates the programusing System.exit(1)if input is invalidd. Prints the name of the month: “The month is XXXXX”Now, this time, write a class, NumberToMonthUsingSwitch, that does the same but uses the switch statement.Tips Use the switch statement along with case and break Use the System.exit(1) in the default to terminate the programSubmission Copy and paste your code Screen shot the console with user input of three example months (one invalid input, two anymonth)Sample RunEnter the month of the year - number 1 to 1277Invalid InputEnter the month of the year - number 1 to 122The month is FebruaryEnter the month of the year - number 1 to 1210The month is October
Ask the user to enter the month of the year (number 1 through 12): “Enter the month of the year - number 1 to 12”
b. Get the month using a Scanner
c. checks for invalid input (i.e. numbers that are not 1 – 12) and terminates the program
using System.exit(1)if input is invalid
d. Prints the name of the month: “The month is XXXXX”
Now, this time, write a class, NumberToMonthUsingSwitch, that does the same but uses the switch statement.
Tips
Use the switch statement along with case and break
Use the System.exit(1) in the default to terminate the program
Submission
Copy and paste your code
Screen shot the console with user input of three example months (one invalid input, two any
month)
Sample Run
Enter the month of the year - number 1 to 12
77
Invalid Input
Enter the month of the year - number 1 to 12
2
The month is February
Enter the month of the year - number 1 to 12
10
The month is October
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images