Write a class, NumberToMonth, which does the following:a. Ask the user to enter the month of the year (number 1 through 12): “Enter the month ofthe 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”Tips Use a multi-way if-else statementSubmission 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 12)77Invalid InputEnter the month of the year (number 1 to 12)6The month is JuneEnter the month of the year (number 1 to 12)12The month is December
Write a class, NumberToMonth, which does the following:
a. 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”
Tips
Use a multi-way if-else statement
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)
6
The month is June
Enter the month of the year (number 1 to 12)
12
The month is December
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images