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
Write a simple Html structure and explain the meaning of each line
seropon [69]

Answer:

HTML stands for HyperText Markup Language and is the basic structural element that is used to create webpages. HTML is a markup language, which means that it is used to “mark up” the content within a document, in this case a webpage, with structural and semantic information that tells a browser how to display a page. When an HTML document is loaded by a web browser, the browser uses the HTML tags that have marked up the document to render the page’s content.

There are three types of code that make up a basic website page. HTML governs the structural elements, CSS styles those elements, and JavaScript enables dynamic interaction between those elements.

7 0
3 years ago
What is a critical consideration on using cloud-based file sharing and storage applications.
Dmitry [639]

Answer:

Determine if the software or service is authorized

Explanation:

:)

3 0
2 years ago
How to assign some object key values to other name react const.
notsponge [240]

Props are an ordinary object of React that follow the immutable properties. This simply means that you cannot change their value throughout the component. Props and states are in the form of an object which contains the number of key value pairs that could be used to render the value of the objects

8 0
2 years ago
toThePowerOf is a function that accepts two int parameters and returns the value of the first parameter raised to the power of t
zlopas [31]

Answer:

cubeVolume = toThePowerOf(cubeSide, 3);

Explanation:

The line above accomplishes the task of calling the function toThePowerOf(). We are told in the question that the method accepts two int parameters these integer parameters are given as cubeSide and 3. They are passed as arguments when the method is called. The result of the function's computation is then assigned/stored to the the variable cubeVolume.

4 0
3 years ago
Lets assume we are writing a system to backup a list of transactions: class Transaction 1 String TransactioniD: Date TranactionT
zhannawk [14.2K]

Answer:

The answer is "Option d"

Explanation:

In this question, the easiest way that will save the payment on your database in such a process ID-sorting list would be to mark a payment, that's been recorded mostly on the database whenever this payment became used serial number is not transaction ID, and the wrong choice can be defined as follows:

  • In choice a, It is wrong because it may be processed, however, payments aren't entered through our process, which does not help remove older.
  • In choice b, the unordered list would not enable any transaction to only be retrieved, that's why it is wrong.
  • In choice c, it will not be helpful because the includes video is either begin or complete the payment, it will not be helpful to hold it with transaction time.
  • In choice e, this approach won't help to identify the payments since one date will have a lot of payments over a certain account.
6 0
3 years ago
Other questions:
  • _____ are the supertiny on-off switches in a chip that work collectively to calculate or store things in memory. Transistors Mul
    10·1 answer
  • Define a function CoordTransform() that transforms the function's first two input parameters xVal and yVal into two output param
    11·1 answer
  • Consider a company that needs to sort an array of structures of type Customer by balance, with the largest balance first. Here i
    10·1 answer
  • It is a good idea to include your teacher’s name on a title page.
    12·2 answers
  • Given the variable ip, already declared as a pointer to an integer, write the code to dynamically allocate memory for a single i
    15·1 answer
  • The physical elements needed for the production of digital media, such as computers, servers, and so on are called the {Blank}
    8·1 answer
  • A program is run line by line to determine the source of a logic error. Which best describes the specific tool being used?
    11·2 answers
  • Helppppppppppppppp me please Can i have help for a ggogle class room
    5·1 answer
  • Which discipline focuses on the design of computer hardware?
    5·2 answers
  • Which subscription service complements App-ID by enabling you to configure the next-generation firewall to identify and control
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!