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]
2 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]2 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
Containers for contaminated sharps must have several characteristics. What’s missing from the list? PuContainers for contaminate
Nadya [2.5K]
All sharps containers must be stored upright,be puncture-resistant, be labeled or color-coded red & leakproof on both the sides & the bottom! The last one is the one missing!
4 0
2 years ago
Read 2 more answers
True or False. A Windows Server 2016 that was installed in Desktop Experience mode can be converted to Server Core mode.
9966 [12]

When we install the Windows Server 2016 in Desktop Experience mode we cannot change it to Server Core mode. To change it we must uninstall it and reinstall it changing the mode (False).

<h3>What is Windows Server?</h3>

Windows Server is the name of a line of products created and marketed by the Microsoft Corporation software company.

One of its products is Windows Server 2016, this server was characterized by having two modes that were:

  • Desktop Experience
  • Server Core

However, it had the difficulty that the user could not switch between the two modes but had to uninstall and install the mode he wanted to use.

Learn more about Windows Server in: brainly.com/question/9426216

8 0
2 years ago
The icons to insert pictures and clip art in the PowerPoint application are located in the _____ grouping on the Insert tab.
saul85 [17]
The icons to insert pictures and clip art are located in the images grouping on the insert tab.
3 0
3 years ago
Name the six parts of the product development life cycle.
Nuetrik [128]

Answer:

Development, Introduction, Growth, Maturity and Decline.

Explanation:

5 0
2 years ago
Read 2 more answers
How do I do a PowerPoint
kirill115 [55]
It is like this: . You just put a circle and that is a power point
4 0
3 years ago
Read 2 more answers
Other questions:
  • Jill needs to create a chart for technology club that shows what percentage of total students in the school play video games. Wh
    11·2 answers
  • Despite its vivid design, the website for Lolly's Bookstore did not seem to attract customers who lingered. In fact, most websit
    13·1 answer
  • Write a program that ask the user to enter air water or Steele and the distance that a sound wave will travel in the medium the
    6·1 answer
  • Which wireless communication technology is most likely used when synchronizing device information to an automobile?
    9·1 answer
  • g If a class named Student has a data member named gpa , and one of its member functions has a parameter also named gpa , how ca
    7·1 answer
  • Heidi uses her computer to write articles for a newspaper. She uses a program to listen to the articles before she submits them
    5·1 answer
  • Who invented the speaker?
    14·2 answers
  • Project light with a system of lenses used for projecting slides or film into a screen.
    5·1 answer
  • Please answer the following question in Verilog.
    11·1 answer
  • What is the basic body structure of html.
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!