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
inna [77]
3 years ago
13

Write a program, named NumDaysLastNameFirstName.java, which prompts the user to enter a number for the month and a number for th

e year. Using the information entered by the user and selection statements, display how many days are in the month. Note: In the name of the file, LastName should be replaced with your last name and FirstName should be replaced with your first name. When you run your program, it should look similar to this:
Computers and Technology
1 answer:
Alexandra [31]3 years ago
3 0

Answer:

Explanation:

The following code is written in Java and uses Switch statements to connect the month to the correct number of days. It uses the year value to calculate the number of days only for February since it is the only month that actually changes. Finally, the number of days is printed to the screen.

import java.util.Scanner;

public class NumDaysPerezGabriel {

   public static void main(String args[]) {

       int totalDays = 0;

       Scanner in = new Scanner(System.in);

       System.out.println("Enter number for month (Ex: 01 for January or 02 for February): ");

       int month = in.nextInt();

       System.out.println("Enter 4 digit number for year: ");

       int year = in.nextInt();

       switch (month) {

           case 1:

               totalDays = 31;

               break;

           case 2:

               if ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))) {

                   totalDays = 29;

               } else {

                   totalDays = 28;

               }

               break;

           case 3:

               totalDays = 31;

               break;

           case 4:

               totalDays = 30;

               break;

           case 5:

               totalDays = 31;

               break;

           case 6:

               totalDays = 30;

               break;

           case 7:

               totalDays = 31;

               break;

           case 8:

               totalDays = 31;

               break;

           case 9:

               totalDays = 30;

               break;

           case 10:

               totalDays = 31;

               break;

           case 11:

               totalDays = 30;

               break;

           case 12:

               totalDays = 31;

       }

       System.out.println("There are a total of " + totalDays + " in that month for the year " + year);

   }

}

You might be interested in
I need advice, please try to give a full paragraph and include a p r o s and c o n s list, no l i n k s please, it would mean so
Vlad [161]

Answer:

I think you should do what are passionate about. therefore it might gain more followers. Also so it's not boring and it's enjoyable for you. also it will be easier for you to do. the pros are you will put in extra efforts, it will make you happy, it will workout longer, it can help you grow as a person. the cons are you may lose followers, it may be hard to think of content, you might not make money, people may try to bring you down.

i think you should make a different account and try it. either make another account for art or make another for vlogs.

But honestly just try it out and see how it goes.

Explanation:

7 0
2 years ago
Which statement best describes one reason why assembly language is easier
viktelen [127]

Answer:

machine language uses binary code and assembly language uses mnemonic codes to write a program.

Explanation:

In a nutshell, machine language uses binary code, which is almost impossible for humans to decipher, whereas assembly language uses mnemonic codes to write a program. Mnemonic codes make it simpler for humans to understand or remember something, and so make the language a bit easier for humans to use than machine code.

6 0
2 years ago
In PowerPoint, a type of chart that, rather than showing numerical data, illustrates a relationship or logical flow between diff
Lynna [10]

Answer:

A. SmartArt

Explanation:

SmartArt is a graphical tool used to visually communicate information.

8 0
3 years ago
You are using a wireless client adapter with a site survey utility and a notebook computer to perform a manual site survey in a
Oduvanchick [21]

Answer:

Signal strength and SNR

Explanation:

The signal strength and SNR are two important values to record during the manual site survey process. Signal loss and propagation loss have different effects, and packet retries are more of an issue with dynamic rate selection.

5 0
2 years ago
Which options most accurately describe the information that should be included in note-taking? SELECT ALL THAT APPLY
velikii [3]
I think: B,C,D. You do not need to write notes on a thing that you will only see, but you need a date, key words, and main ideas.
4 0
3 years ago
Read 2 more answers
Other questions:
  • Your website is currently at position 5 in organic search. On a monthly basis you currently get on average 5,432 clicks and 32 c
    7·1 answer
  • Sonora wants to extend the cells to be added in her formula. what is the quickest way to add more sells?
    10·2 answers
  • A word processing program would probably be used to: 
    8·1 answer
  • Pinterest, a visual bookmarking Website, logs more than 14 terabytes of new data each day, which means its storage needs are con
    10·1 answer
  • What is internet marketing??
    13·1 answer
  • Plz tell me how to get my deleted account back you will be highly PRAISED!!!!!!!!!!
    14·2 answers
  • In Windows, which menu allows you to view file characteristics?
    14·1 answer
  • AI is not embraced everywhere in every industry because _______.
    7·1 answer
  • List and briefly define the four main elements of a computer.​
    9·1 answer
  • [2]<br> (c) Describe how the microprocessor can determine when to sound the clock alarm.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!