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

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter9: Advanced Modularization Techniques
Section: Chapter Questions
Problem 13RQ
icon
Related questions
Question

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

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage