1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
agasfer [191]
3 years ago
13

Create an enumeration named Month that holds values for the months of the year. With JANUARY equal to 1, FEBRUARY equal to 2, an

d so on through DECEMBER equal to 12. Write a program named MonthNames that prompts the user for a month integer. Convert the user’s entry to a Month value, and display it. Make sure your integer prompt message does not contain any month names (January, etc.) as this will cause the tests to fail! For Example: "Enter a month number >> " does not contain month names and will work properly.
Computers and Technology
1 answer:
maria [59]3 years ago
4 0

Answer:

import java.util.Scanner;

public class Question {    

   public enum Months{

       JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER

   }

   public static void main(String args[]) {

     

     Scanner scan = new Scanner(System.in);

     System.out.println("Enter a month number>>: ");

     int inputNumber = scan.nextInt();

     

     if(inputNumber > 12 || inputNumber < 1){

         System.out.println("Please enter a valid number.");

     } else {

         System.out.println(Months.values()[inputNumber - 1]);

     }

   }

}

Explanation:

The import statement at the top of the class is to help us receive user input via the keyboard. The class was defined named "Question". Then the enum was declared listing all the months. Then the main function was declared. The Scanner object was created as scan, then the user is prompted for input which is assigned to inputNumber. The user input is validated to be within the range of 1 - 12; if it is outside the range, the user shown an error message. If the input is correct, the appropriate month is displayed to the user. To get the appropriate month, we subtract one from the user input because the enum class uses the zero-index counting; it start counting from zero.

You might be interested in
Please help me with this question. I don’t get it
IRISSAK [1]

Answer:

d

Explanation:

i took the test

3 0
3 years ago
Read 2 more answers
Alice has 1/5 as many miniature cars as Sylvester has slyvester has 35 miniature cats how many miniature cars dose Alice have
garik1379 [7]
Alice has 7 miniature cars
5 0
4 years ago
_____ is the operation of setting a variable to a value.
Helen [10]

Answer:

Assignment is the operation of a variable to a value

3 0
4 years ago
What is the QOS model?
Andre45 [30]

Answer:

Quality Of Service

Explanation:

Technology that manages data traffic to reduce packet loss, latency and jitter on the network. QoS controls and manages network resources by setting priorities for specific types of data on the network.

5 0
3 years ago
An html element that describes the content of a web page is called a(n):
Marizza181 [45]
I think its <tagname> content right here </tag name>
3 0
3 years ago
Other questions:
  • How to create a delete button in Python?
    15·1 answer
  • When you open a stream for both reading and writing files, what must you always remember to do at the end?
    10·1 answer
  • Which of the following is not the name of an air mass?
    7·1 answer
  • Which quality is likely to ensure consistent career growth in the computer field?
    9·2 answers
  • What layout manager should you use so that every component occupies the same size in the container?
    5·1 answer
  • What is a computer OPERATING SYSTEM?
    10·1 answer
  • In order for storage devices to be prepared for use, they must be ____________ Group of answer choices pre-prepared loaded initi
    11·2 answers
  • Choose the accurate answer from the drop-down choices.
    11·1 answer
  • What are the 7 c s of communication​
    9·1 answer
  • What has global css rulesets of an angular 8 project mcq.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!