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
Xanadu was to be a full-blown multimedia computer that could embody any medium.a. Trueb. False
kondor19780726 [428]

Answer:

b. False

Explanation:

Xanadu is a project formulated by a certain Ted Nelson, and was originally intended to be a machine-language program with the capability of saving and showing various documents side by side, while the availability of editing function is also available.

Hence, in this case, it is FALSE that Xanadu was to be a full-blown multimedia computer that could embody any medium

7 0
3 years ago
Click _______ to add a new column to a table.
Sophie [7]
The answer is Insert control B

5 0
4 years ago
Read 2 more answers
What are the special features of fifth generation that makes it different from the other generations?​
Salsk061 [2.6K]

Answer:

The answer to this question is given below in this explanation section.

Explanation:

               "features of fifth generation"

The fifth generation computer system was an initiative by japans ministry of international trade and industry,begun in 1982,to create computer using massively parallel computing and logical programming.It was to be the result of massive government industry research project in japan during the 1980.It aimed to create an epoch making computer with supercomputer liked performance and to provide a platform for future development in artificial intelligence.There was also an unrelated Russian project also named as the fifth generation computer.

The term fifth generation was untended to convey the system as being a leap beyound existing machines.In the history of computing hardware,computer using vacuum tubes were called the first generation;transistors and diodes,the second;integrated circuits,the third;and those using microprocessors,the fourth.Whereas previous computer generation had focused on increasing the number of logic elements in a single CPU,the fifth generation,it was instead turn to massive numbers of CPU for added performance.

5 0
3 years ago
To create an effective study schedule, a student must guess the amount of time needed for studying. write down all activities an
Inessa [10]

Answer:

B) write down all activities and commitments

Explanation:

It seems the most logical.

3 0
3 years ago
Read 2 more answers
A _____ is a predefined text format that includes multiple formatting options.
VladimirAG [237]
A style is a predefined text format that includes multiple formatting options.
7 0
3 years ago
Other questions:
  • Question 1
    9·1 answer
  • A half-life is the amount of time it takes for a substance or entity to fall to half its original value. Caffeine has a half-lif
    11·1 answer
  • Which software application should be used to communicate in writing about an upcoming event?
    12·2 answers
  • What is the most important external issue when using social media in emergency management?
    6·1 answer
  • Compare the specialized and statistical functions in excel
    10·1 answer
  • What will be displayed if the following Java code segment is run? System.out.println("one "); System.out.print("two "); System.o
    12·1 answer
  • Freee poiiiiintttttssss​
    14·2 answers
  • Use the drop-down menus to match each description to its corresponding term.
    7·1 answer
  • bro i got banned for posting an amazing bulk pic, but this dude literally posted an inappropriate, dafuq is wrong with this bann
    8·2 answers
  • How could this code be simplified?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!