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
Can some give me engineers names that start with the letter A-Z
Nadya [2.5K]

Answer:

elon musk/ bill gates/ jeff bezos/ henry ford/ tim cook

Explanation:

i googled it/ i added more

6 0
3 years ago
Assume the variable sales references a float value. Write a statement that displays the value rounded to two decimal points.Assu
romanna [79]

Answer:

The statement is as follows:

print("{0:,.1f}".format(number))

Explanation:

Required

Statement to print 1234567.456 as 1,234,567.5

To do this, we make use of the format keyword, and we set the print format in the process.

To round up number to 1 decimal place, we use the following format:

"{0:,.1f}"

To include comma in the thousand place, we simply include a comma sign before the number of decimal place of the output; i.e. before 1

"{0:,.1f}"

So, the print statement is:

print("{0:,.1f}".format(number))

3 0
3 years ago
How do I mark someone brainiest
svet-max [94.6K]

Answer:

when someone answers your questio correctly, you will see a red crown. Click on that and mark them the most brainiest

Explanation:

3 0
2 years ago
Read 2 more answers
...............................
Gemiola [76]

............................

Mark me brainliest^^

7 0
2 years ago
Read 2 more answers
The collection of all component frequencies iscalled _____________
yKpoI14uk [10]

Answer:

The answer is Frequency Spectrum.

Explanation:

The frequency spectrum is range of all component frequencies.It contains all the waves which are as following:-

Gamma Rays

X-Rays

Ultraviolet

Visible light.

Infrared

Micro wave

Radio wave

These all waves have their range of frequencies.The waves that are visible to us is only the visible light.

4 0
3 years ago
Other questions:
  • The function takes two string parameters; the first is the name of a file and the second is text. Complete the function to appen
    7·1 answer
  • Which are valid double statements for java? double a = 0; double b = -1.0; double c = -425; double d = 6340; double e = -1.0; do
    12·2 answers
  • Which of the following is not a metamorphic agent?
    8·2 answers
  • Why did Simon bring Michael home?​
    9·2 answers
  • Write a Java application that uses the Math class to determine the answers for each of the following: a. The square root of 37 b
    10·1 answer
  • AYYOOOO CAN YOU HELP A GIRL OUUTT???
    11·1 answer
  • How has the global marketplace used emerging technologies to expand businesses
    14·1 answer
  • Consider the following code segments that are potential replacements for /* missing code */.
    6·1 answer
  • 1 point
    5·2 answers
  • Is there a way for me to play a .mp3 file from my computer using Atom?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!