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
How to make logo black and white in paint?
Pie
Change the color to black and white
7 0
3 years ago
Who owns the internet? <br><br> A.) Nobody<br> B.) W3C<br> C.) NSCA<br> D.) The US Military
crimeas [40]

your answe is A i believe


I hope that this helps

and that you have a wonderful day

3 0
3 years ago
What is one problem caused by spending too much time studying at your computer? A. It increases stress and negatively affects yo
nignag [31]

Answer:

A - It increases stress and negatively affects your sleep.

Hope that helps. x

4 0
2 years ago
Within the try clause of a try statement, you code a. all the statements of the program b. a block of statements that might caus
SVETLANKA909090 [29]

Answer:

B) A block of statement that might cause an exception.

Explanation:

Exception handling is a good programming technique that prevents our program from crashing when an exception occurs during execution. The try clause is used with a catch to handle any exception that might occur, so whenever a statement that might cause an exception is to be used, this should be contained in a try statement block of code.

5 0
3 years ago
Jenae helps maintain her school web site and needs to create a web site poll for students. Which tool will she use? JavaScript H
irga5000 [103]

Answer:

Text Editor

Explanation:

What the question implies is that, what tool will she need to create the website.

And the answer is a text editor; this is so because the other three options are web development languages used in developing a website but the text editor is where she'll write her line of codes to create the required website poll.

Example of usable text editors are notepad and notepad++ etc.

4 0
3 years ago
Read 2 more answers
Other questions:
  • Andre is teaching a class without the software development cycle while teaching the analyst phase which task should Andre mentio
    8·1 answer
  • Give a recursive algorithm that takes as input a string s, removes the blank characters and reverses the string. For example, on
    7·1 answer
  • I made Pico with a Ray Gun (Next is Dad/Tankman)<br><br> Opinons?
    11·2 answers
  • Hey im b---o---r---e---d dont report cuz if u do ur l a m e :)
    14·1 answer
  • When we code an algorithm, we need to provide the commands in the order we want the
    10·1 answer
  • An Excel file that contains one or more worksheets
    15·1 answer
  • Set of general format used to write program in any programming language?​
    10·1 answer
  • A technology _________ occurs when the ability of a company to operate is impaired because of a hardware, software, or data outa
    7·1 answer
  • Which sentence describe internet safety precautions?
    5·1 answer
  • Can anyone tell me about Microsoft some important features for partical
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!