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
A ____ is a battery-operated power source directly attached to one or more devices and to a power supply (such as a wall outlet)
bagirrra123 [75]
Universal power supply
3 0
3 years ago
Which of the following is true of an enterprise search software? Select one:
bekas [8.4K]

Option a. It matches a user’s query to many sources of information.

Explanation:

Enterprise search software extracts data from various sources to resolve user's query. It is basically needed by businesses. Businesses needs to store, retrieve and track digital information. The various data sources are obtained from information stored in e-mail servers, application databases, intranet sites, websites etc.

Enterprise search system searches data records found within organisation. Thus option A is accurate that it matches user's query to many sources of information is very much accurate.

5 0
3 years ago
The color in a circle is a _____________ data type.
erik [133]

Answer:

b

Explanation:

7 0
3 years ago
Which of these is an example of an online workspace?
irakobra [83]
A website that hosts a companies documents
8 0
2 years ago
What term is used to describe selecting and viewing information in a database?
Rama09 [41]

A terminology which is used to describe selecting and viewing information stored in a database is known as query.

<h3>What is query?</h3>

A query can be defined as a computational request, selection and view of the data that are stored in a database table, from existing queries, or even from a combination of both a database table and existing queries.

In this scenario, we can infer and logically conclude that query is a terminology that is typically used to describe selecting and viewing of information that are stored in a database.

Read more on query here: brainly.com/question/25266787

#SPJ12

8 0
2 years ago
Read 2 more answers
Other questions:
  • What will be the biased exponent of 1,100.1? <br> A:130<br> B:127<br> C:-127<br> D:2^3
    12·2 answers
  • The computer that provides information or resources to the client computers on the network is called a(n) ________.
    5·1 answer
  • What safety precaution should you take while filling the fuel tank of a gasoline-powered boat?
    8·1 answer
  • Search engines enable you to
    9·2 answers
  • Technology can most broadly be defined as anything that does which of the following ?
    11·1 answer
  • What memory stores instructions that tell the computer how to start up?
    10·1 answer
  • How to delete Brainly account ?​
    12·1 answer
  • Not all hardware is connected with wires, some hardware might be connected wirelessly with
    9·1 answer
  • Write down a scratch program which:
    5·1 answer
  • What is a network computer that processes requests from a client server​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!