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
Please help! I need to submit this quick!
taurus [48]

Answer:

B, C, A

Explanation:

i think those are right

3 0
3 years ago
Read 2 more answers
Professor Midas drives an automobile from Newark to Reno along Interstate 80. His car’s gas tank, when full, holds enough gas
zmey [24]

Answer:

The GREEDY Algorithm

Explanation:

Based on the situation given in question, the Greedy algorithm shall give the optimal solution to professor

Suppose that the cities are at locations0 =x0< x1< . . . < x

We shall use the induction method to prove that G is the optimal solution valid for numbers less than n

We assume another solution Z which we initially consider to be optimum as well, based on that when Z fills the tank, it fills it to full level

Let us state the values in case of n intervals. Given below, we say that g1 is the first stop and z1 is also the first stop.

This can be written as ;

G=g1, g2, . . . , gk

Z=z1, z2, . . . , zk’

Here k’ <= k and k < n

Let I be an idex where for the first time gi is not equal to zi

Considering t= maxi Zi

Z′=g1, z2, z3, . . . , zk′

Now since z2, z3, . . . , zk′ should be an optimal stopping pattern for the problem otherwise we have chosen Z, with smaller gas filling (not feasible)

Using induction hypothesis we conclude thatg2, . . . , gk is an optimal stopping pattern, which is based on greedy algorithm

7 0
3 years ago
Selecting the Tiled windows arrangement option places the windows in a(n) _______ pattern on the screen.
Archy [21]

Answer:

Selecting the Tiled windows arrangement option places the windows in a(n) Grid pattern on the screen.

Explanation:

3 0
2 years ago
Why did it take hundreds
levacccp [35]
Before that there was no way for the image to be recorded and fixed on a surface
5 0
2 years ago
10) What is the BEST way to rewrite sentence (1) to make it more
givi [52]
I believe the answer is D. It makes more sense and is the most correct grammatically.

Hope this helped and pls mark as brainliest!

~ Luna
3 0
2 years ago
Read 2 more answers
Other questions:
  • Given the following adjacency matrix, what is the approximate rank vector after one iteration of the power iteration method (use
    10·1 answer
  • 1. Caches are important to providing a high-performance memory hierarchy to processors. Below is a list of 32-bit memory address
    7·1 answer
  • ____________ facilitates the processes that help an organization function by applying information and communication technologies
    5·1 answer
  • Write a program that reads from the user any three points in two dimensional space: x1, y1, x2, y2, x3, y3. Assume these points
    13·1 answer
  • List safety conditions when downloading shareware, free free where, or public domain software
    14·1 answer
  • What are some random fun facts about Technology?
    12·1 answer
  • My brainly is no hello friend , i need you can you help me, please okay
    13·2 answers
  • Something I should look for when trying to decide if a source is credible is the publication's ....
    10·1 answer
  • Which of the following is true about stateless applications?
    9·1 answer
  • A continuous and differentiable function f(x) with the following properties: f(x) is decreasing at x=−5 f(x) has a local minimum
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!