answer.
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
pshichka [43]
2 years ago
13

Write a program that prompts the user to enter the month and year and displays the number of days in the month. For example, if

the user entered month 2 and year 2000, the program should display that February 2000 has 29 days. If the user entered month 3 and year 2005, the program should display that March 2005 has 31 days.Here is a sample run of this program:Enter a month in the year (e.g., 1 for Jan): 1Enter a year: 2009January 2009 has 31 daysExercise 3.11Liang, Y. Daniel. Introduction to Java Programming (8th Edition)
Computers and Technology
1 answer:
valentinak56 [21]2 years ago
3 0

Answer:

Following are the program in JAVA language  

import java.util.Scanner; // import package

import java.util.Calendar; // import package

public class Main // class main  

{  

public static void main(String[] args) // main function  

{  

Scanner input = new Scanner(System.in); // for user input  

Calendar calendar = Calendar.getInstance(); //get calendar instance for methods  

int nYear , nMonth , date =1 , nDays;

String MonthOfName = "";

 System.out.print(" Enter a month in the year :");

 nMonth = input.nextInt(); //input Month

 System.out.print("Enter a year :");

 nYear = input.nextInt(); //Input Year

 switch (nMonth) //Find month name via 1-12

 {

  case 1:

MonthOfName = "January";

nMonth = Calendar.JANUARY;

break;

case 2:

MonthOfName = "February";

nMonth = Calendar.FEBRUARY;

break;

case 3:

 MonthOfName = "March";

nMonth = Calendar.MARCH;

break;

 case 4:

 MonthOfName = "April";

nMonth = Calendar.APRIL;

 break;

 case 5:

MonthOfName = "May";

nMonth = Calendar.MAY;

break;

case 6:

MonthOfName = "June";

nMonth = Calendar.JUNE;

break;

case 7:

 MonthOfName = "July";

nMonth = Calendar.JULY;

break;

 case 8:

MonthOfName = "August";

nMonth = Calendar.AUGUST;

break;

case 9:

MonthOfName = "September";

nMonth = Calendar.SEPTEMBER;

break;

case 10:

MonthOfName = "October";

nMonth = Calendar.OCTOBER;

break;

case 11:

 MonthOfName = "November";

nMonth = Calendar.NOVEMBER;

break;

case 12:

MonthOfName = "December";

nMonth =Calendar. DECEMBER;

         }        

 calendar.set(nYear, nMonth, date); // set date to calender to get days in month

nDays=calendar.getActualMaximum(Calendar.DAY_OF_MONTH); // get no of days in month

System.out.println(MonthOfName + " " + nYear + " has " + nDays + " days."); //print output

}

}

Output:

Enter a month in the year : : 09

Enter a year : 2019

September 2019 has 30 days.

Explanation:

In this program we have take two user input one for the  month and other for the year Also take two variables which are used for storing the month name and no of days in a month. with the help of switch we match  the cases  and store the month value .After that  set the date to calender with help of calendar.set(nYear, nMonth, date) method and  To get the number of days from a month  we use  calendar.getActualMaximum(Calendar.DAY_OF_MONTH);  method and finally print year and days.

 

     

You might be interested in
3.A customer has a system with a Gigabyte B450 Aorus Pro motherboard. He wants to upgrade the processor from the AMD Athlon X4 9
Burka [1]

Answer:

The upgrade is possible and it will yield a remarkable  increase in performance

Explanation:

It is a newer product, there is tendency of having a better application compatibility/performance

It has much higher multi threaded performance which is around 522% higher. This allows for higher performance in professional applications like encoding and heavy multitasking compared to the previous.

When considering gaming, it has higher performance compared to the previous.

5 0
2 years ago
Mitchell has noticed that his co-workers are unable to open attachments in the emails he sends. What is one possible reason for
hammer [34]
Maybe it could be the website or the email it self
 <span />
8 0
2 years ago
Which among the following enhances WS-Security to facilitate a mechanism for issuing, renewing, and validating security tokens?
Aleksandr-060686 [28]

Answer:

a. WS-Trust

Explanation:

WS-Trust can be defined as a WS-specification as well as OASIS standard that help to provides extensions to WS-Security, in order to facilitate a mechanism for issuing, renewing, as well as validating of security tokens which is why the aim and objectives of WS-Trust is to help and enable applications to construct trusted SOAP message exchanges.

Nevertheless WS-Trust enables the issuance as well as the dissemination of credentials within several and various trust domains.

5 0
2 years ago
A process is moved to wait queue when I/O request is made with:_______ A. non-blocking I/O B. blocking I/O C. asynchronous I/O D
Sidana [21]

Answer:

B. blocking I/O

Explanation:

           Most of the input and output request placed  to the computer considers the blocking request. It means that the controls given cannot be returned to the given application until and unless the input/output is complete.

           Thus, blocking the input/output does not return till the input and output is complete.

            With a blocking I/O, the process is moved to a wait queue when the I/O request is made, and it moved backs to the ready queue as soon as the request is complete, thereby allowing the other processes to run in the meantime.

Thus (B) blocking I/O is the answer.

7 0
2 years ago
Scenario 1: Richman Investments provides high-end smartphones to several employees. The value of each smartphone is $500, and ap
vfiekz [6]

Answer:

a). SLE =$37.5

b). ARO =75

c). ALE = $2,812.5

Explanation:

a).Single loss Expectancy (SLE) is starting point in determining the single loss of an asset that will occur and calculated this;

SLE = asset value * exposure factor.

Asset value =$500,

Exposure factor is simply the percentage of asset lost.

In this case out of 1000 phones, 75 were damaged or loss.

In percentage;

75 ÷ 1000 =0.075, 0.075×100=7.5%(exposure factor).

Therefore,

SLE = $500×7.5%= $37.5.

b). ARO - Annual Rate of Occurrence is the number of times a threat on a single asset is expected to occur in one year.

In the case the damage or loss occured in 75 devices in one year.

c). ALE - Annualized loss Expectancy is the product of SLE and ARO.

Therefore;

ALE = $37.5 × 75 = $2,812.5.

3 0
2 years ago
Other questions:
  • Allows you to manually add an entry to the arp cache that resolves the ip address inetaddr to the physical address etheraddr. wh
    13·1 answer
  • 14. If B3=10 and D5=8, what would the following function return? IF(B3&gt;D5, "Closed", D5-B3) *
    9·1 answer
  • You can press ____ to move the focus through the controls of the form. [page down] [tab] [f5] [f12]
    10·1 answer
  • As in algebra, you can use brackets to override the order of operations Excel follows to perform formula calculations. True or f
    13·1 answer
  • What technology gets its name from the notion that it ignores the traditional A, B, and C class designations for IP addresses?
    14·1 answer
  • Write a program that first reads in the name of an input file, followed by two strings representing the lower and upper bounds o
    8·1 answer
  • In this assignment, you are provided with almost-working code that establishes a TCP socket connection over the INET domain (tho
    11·1 answer
  • Design and document an IP addressing scheme to meet ElectroMyCycle’s needs. Specify which IP address blocks will be assigned to
    11·1 answer
  • Lucy is completing a project as part of a science class using materials she found online. Which of the following is MOST LIKELY
    5·1 answer
  • A small e-commerce company uses a series of Robotic Process Automation solutions to manage the backup of data from individual wo
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!