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
When creating a shape in Word, what are some available options? Check all that apply. adding text to the shape changing the size
netineya [11]

Answer:

adding text to the shape

changing the size of the shape

changing the location of the shape

Explanation:

A word is can be regarded as graphical word processing program on the computer which can be used by users to type and to save documents. The word also has alot of useful tools with TABs such Insert, pagelayout, Design and others. It was developed by Microsoft corporation.

To create shapes in words, these step can be taken;

✓click "insert" at the interphase

✓Then look for "shapes" and select the needed shape.

✓To draw the shape, it should be clicked then drag holding the mouse.

✓after drawing, any modifications can be made, text can be added and lots more.

It should be noted that When creating a shape in Word, some of available options are;

✓adding text to the shape

✓changing the size of the shape

✓changing the location of the shape

8 0
3 years ago
Which of the following tasks are suitable for creating an algorithm? Choose all that apply
Hatshy [7]

A tasks are suitable for creating an algorithm are:

  • giving directions to a location.
  • solving a math problem.
  • tracking money in a bank account.
  • tracking the number of items in inventory.

<h3>What is algorithm?</h3>

An algorithm is known to be a form of a procedure that is often employed in the act of solving a problem or carrying out a computation.

Note that in the case above, A tasks are suitable for creating an algorithm are:

  • giving directions to a location.
  • solving a math problem.
  • tracking money in a bank account.
  • tracking the number of items in inventory.

See options below

giving directions to a location

saving time writing a computer program

solving a math problem

tracking money in a bank account

tracking the number of items in inventory

Learn more about algorithm from

brainly.com/question/24953880

#SPJ1

8 0
2 years ago
Why do companies use online collaborative productivity software.
vladimir2022 [97]

Why do companies use online collaborative productivity software? Companies use online collaborative productivity software to allow employees to share document such as reports or spreadsheets and make edits or comments.

4 0
3 years ago
List four reasons of meaningful use that demonstrate the capabilities and processes required for the provider to show active use
Naily [24]

<span>1.       </span>Improve quality of care and reduce health disparities.

<span>2.       </span>Read the orders in the medical record and make sure to read it back again to verify accuracy.

<span>3.       </span>Maintain the security and privacy of patient health information.

<span>4.       </span>Talk to the patients and families in management of their health care.






7 0
3 years ago
Marco had a database that showed the first, second, and third favorite ice cream flavors for each person in his school. He used
Maksim231197 [3]

Answer:

B

turned data into information

7 0
2 years ago
Read 2 more answers
Other questions:
  • Assign to avg_owls the average owls per zoo. Print avg_owls as an integer. Sample output for inputs: 1 2 4 3
    7·1 answer
  • What might be the best response to a cyberbuly attack
    6·2 answers
  • A web __________, such as internet explorer or mozillaâs firefox, allow users to access the world wide web.
    10·1 answer
  • What is the traditional cognitive perspective ofHCL?
    12·1 answer
  • Suppose there are two hosts, S and R. They are communicating over a TCP connection, and R has already received from S al bytes f
    11·1 answer
  • A local cinema allows customer to make a movie ticket reservation. A customer can be
    6·1 answer
  • What refers to a collection of small sections of code that are stored together to solve many everyday programs?
    11·2 answers
  • Josh needs to write a research report for his Civics class. Which file type will allow him to save his file? (5 points)
    12·1 answer
  • Does anyone have Rblx? if so write your username
    6·1 answer
  • 19. Fatigue can help improve your reaction time.<br> False<br> O True
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!