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
True or false mobile devices need to work within limited screen space
eduard
A phone may have a 4 inch screen and so it cant just extend to 5 inches. So it would he true
3 0
2 years ago
Read 2 more answers
Your organization has an Active Directory domain. One of the users, Bill, should not have read access to a folder named Accounti
Alborosie

Answer: D. Deny read access to the Accounting folder for Bill through shared access security.

Explanation:

The statement that describes how to stop Bill from having read access to the folder without impacting any other users on the network is to deny read access to the Accounting folder for Bill through shared access security.

It should be noted that the local access security cannot be used in this case because the folder is shared from a network server that is within the active directory domain.

5 0
2 years ago
While designing a website, a(n) ____ allows you to identify the specific amount of space used on a particular page before it con
Aleks [24]
The answer would be A: wireframe, im pretty sure...

Hope this helped!! :)

8 0
3 years ago
Read 2 more answers
Which form of malware contains hidden code that is triggered by meeting or reaching a specific condition? (A) Trap door (B) Viru
Alborosie

Answer:

D- Trojan Horse

Explanation:

Trojan horse is a malware that has hidden code and look legitimate in order to damage or transfer harmful action on the computer.

Example hackers can disguise as Trojan horse by spying on the victims computer in order to gain access to sensitive data on the computer over the network.

3 0
2 years ago
The major difference between a template and another document is in.​
tensa zangetsu [6.8K]
Templates in pandadoc are used for generic content that you intend on using multiple times, while documents are used for specific information. In order to send a document, you must first creat it from an existing template.
4 0
3 years ago
Other questions:
  • Most programming languages provide loop statements that help users iteratively process code. In Coral you can write loops that h
    15·1 answer
  • A 2-dimensional 3x3 array of ints, has been created and assigned to tictactoe. Write an expression whose value is true if the el
    10·1 answer
  • Whenever Jim starts his laptop, he sees some commands and numbers appearing on his screen. These instructions are being processe
    12·2 answers
  • Rachel wants to post content from digital cameras on the web. Which online tool will help Rachel to post and edit content on a w
    5·1 answer
  • Outlines are effective because
    13·2 answers
  • Two-factor authentication can best be breached by the adversary using:________. a. social engineering attack b. using sniffers l
    10·1 answer
  • Llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
    7·1 answer
  • Where can you find your EFC
    8·2 answers
  • What is the big-O performance estimate of the following function?
    15·2 answers
  • Which of the following are true if you pay only the minimun amount each month towards your credit card bill? You will be charged
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!