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]
3 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]3 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 insert header and page number in word 2016?
AleksAgata [21]
Insert - Header - choose header of your choice. Page numbers are below the Header icon

3 0
3 years ago
The first popular personal computer with a graphical user interface was the Apple Macintosh. Compaq Presario. IBM PC. NeXT works
Pavlova-9 [17]

Answer:

The answer is the Apple Macintosh

Explanation:

The Apple Macintosh PC was the first widely sold and most popular PC with a GUI. It was based on its earlier predecessor called the Apple Lisa which was later killed by the Apple Macintosh OS. Prior to the Apple Macintosh was the Xerox PARC which was the first PC to support an OS that was based on GUI. However, the Xerox was not a popular commercial product  and was intended for University research only

7 0
3 years ago
When you increase the screen resolution, windows displays less information on the screen, but the information is larger. true or
leonid [27]
When you increase resolution, say from 1024x768 to 1280x1024, you have more pixels crammed into the same space. The info is still the same number of pixels in size.
4 0
3 years ago
What is computer and define computer types​
lakkis [162]

A computer is one type of machine manage different kinds of programs to perform useful tasks to the users. ... Computer contains wires, transistors, circuits, hardware parts and etc. Computer designs with both software and hardware. Software is a process of preparing program through instructions and data

8 0
3 years ago
Read 2 more answers
It needs to be as simple as possible. Each question is slightly different.1. An arithmetic progression is a sequence of numbers
madam [21]

Answer

can we get a picture of the problem ?

Explanation:

4 0
3 years ago
Other questions:
  • Your crt monitor flickers. what should you do
    6·1 answer
  • "A ____ is loosely defined as a very small device that has some built-in computing or Internet capability"
    15·1 answer
  • What is “GoF” and how does it relate to design patterns?
    7·1 answer
  • a. Create an Abstract class called Vehicle with abstract methods accelerate, stop, and gas, & data of your choice (5 marks)
    12·1 answer
  • Complete the function by filling in the missing parts. The color_translator function receives the name of a color, then prints i
    11·1 answer
  • What does it mean to say that data in an Excel table is “dynamically linked” to a chart? What are the advantages of this feature
    5·1 answer
  • You are a Data Scientist at Anthem Blue Cross Blue Shield. You want to check if a patient will develop diabetes. Please write th
    5·1 answer
  • Select the correct answer from each drop-down menu.
    6·1 answer
  • During critical thinking, the evaluation of information should use
    15·2 answers
  • Anybody know #3 ? I need two ppl to answer this !! Free Brainliest!!
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!