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
abruzzese [7]
2 years ago
9

Write a program that prompts the user to enter a month (1-12) and year, then displays the number of days in the month. For examp

le, if the user entered month 2 and year 2012, the program would display that February 2012 has 29 days. Be careful with February. If the year entered is a leap year, your output should show that February has 29 days. Use the "Case Study: Determining Leap Year" on p. 105 of Introduction to Java Programming for information on how to calculate the leap year. It does not exactly happen every four years.
Computers and Technology
1 answer:
uysha [10]2 years ago
3 0

Answer:

In Java

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

    int mnth, yr;

 Scanner input = new Scanner(System.in);

 System.out.print("Month: ");  mnth = input.nextInt();

 System.out.print("Year: ");  yr = input.nextInt();

 boolean lpYear = (yr % 4 == 0 && yr % 100 != 0) || (yr % 400 == 0);

 if(mnth == 1 || mnth == 3 || mnth == 5 || mnth== 7 || mnth == 8 || mnth == 10 || mnth == 12){

     System.out.print("31 days");  }

 else if(mnth == 2){

     System.out.print(((lpYear) ? "29 days" : "28 days"));  }

else if(mnth == 9 || mnth == 6 || mnth == 4 || mnth== 11){

     System.out.print("30 days");  }

 else{      System.out.print("Invalid");  }

}

}

Explanation:

See attachment for complete program where comments were used as explanation.

Download txt
You might be interested in
What system calls have to be executed by a command interpreter? Why is it usually separate from the kernel?
Licemer1 [7]

Answer:

The exec command by interpreter to start new process

Explanation:

On Unix systems, a call to the fork system must be made followed by a call to the e x e c system to begin a new process. The fork call clones the process that is currently running, while the executive call overlays a new process based on a different executable over the calling process.

It is seperate from Kernal because

It Read user commands or a script and execute them, generally turning them into one or more system calls. Is usual It is not part of the kernel since the command interpreter is subject to change.

6 0
3 years ago
What two actions does the RETI instruction perf orm? Why must these two actions be done in a single instruction, as opposed to a
Bas_tet [7]

Answer:

In assembly language, two instructions control the use of the assembly language procedure.

  • CALL
  • RET

CALL pushed the control to the return address onto the stack and transferred the control.

RET instruction returns the address that placed on the stack by a call instruction.

Explanation:

Action RET instruction

  • The RET instruction pops the address and returns off the stack, which is pointed by the stack pointer.
  • The stack is LIFO in memory at a particular location, and the pointer points offset from the stack location.

RET instruction does its job by consulting the register and memory state at the point when it is executed.

In RET instruction, only register and memory state is executed. Call instruction must save that address that figure out in a register and memory location.

5 0
3 years ago
If nobody buys a ticket to a movie, do they still show it?
Serga [27]

It would depend on the movie and the theater policy.....

Hope this helps have a good day

3 0
3 years ago
Where do you place the logical test argument in an IF function formula?
Inessa [10]

Answer:

The first argument listed after IF

Explanation:

When the two variables are listed next to each other, Excel will find and calculate the correlation between them.

8 0
3 years ago
Read 2 more answers
_______ data would be useful for creating a weekly status report for your manager that should reflect changes in real time.     
elena55 [62]
D. Field data because that it a report of what happened over the week that a manager can reflect on for possible changes.
3 0
3 years ago
Read 2 more answers
Other questions:
  • What task did the u.s. government undertake that many people identify as the birth of the internet
    5·2 answers
  • In scratch the location of a sprite is defined by what?
    10·1 answer
  • Microprocessors can’t directly understand programming languages, so programs have to be converted into _____________ that corres
    15·1 answer
  • Create a program that will read in a Salesperson name, employment status (1=Full-time AND 2=Part-time) and the sales amount.
    5·1 answer
  • The Internet began when a large company wanted to sell products online.
    11·2 answers
  • Select the correct answer.
    10·1 answer
  • What is a fire wall and how does it work
    6·1 answer
  • What is normalization?
    7·1 answer
  • How was kapilvastu named​
    11·1 answer
  • Quick question if anyone knows? How do you give brainlist? Please tell me if you know! ( Here if a chiaki gif for your too lol )
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!