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
pshichka [43]
3 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]3 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
Can someone help me i need to write something for cyber bullying
snow_tiger [21]

cyber bullying is when there is a minor on both ends and when a person has the time to go online to pick on you


3 0
3 years ago
Read 2 more answers
The Universal Containers research lab is publishing its latest research into knowledge articles assigned to the data category "C
Olenka [21]

Answer:

Option C is correct.

Explanation:

The following research laboratory publishes their new work concerning articles of information allocated to the better standards container classification of information. The community manager needs to ensure all of those posts appear across the Tips and Methods subject field for Community users.

Thus, set up an automatic subject assignment and map the list of Tips and Techniques to the Container good practices group.

8 0
3 years ago
What do mobile platforms utilize to stream voice, IP telephony, mobile internet access, video calling, gaming services, cloud co
Anuta_ua [19.1K]

Answer:

4G/5G.

Explanation:

The broadband cellular network technology that mobile platforms utilize to stream voice, IP telephony, mobile internet access, video calling, gaming services, cloud computing, high-definition mobile TV, and mobile 3-D TV is 4G/5G.

4G technology refers to the fourth generation broadband cellular network technology that is typically used for cellular communications on mobile phones and it is considered to have an internet speed that is ten times faster than what is obtainable on the third generation (3G) broadband technology.

Similarly, 5G is the fifth generation broadband cellular network technology that succeeded 4G and it offers higher quality in terms of performance, reliability, availability and efficiency.

As a result of the speed and high quality specifications of the 4G/5G broadband cellular network technology, they are widely used for various communications systems.

5 0
3 years ago
If someone said to you, “Pseudocode is a waste of time! It’s just more work because you end up writing the same program twice,”
myrzilka [38]

Answer:

It allows the designer to focus on main logic without being distracted by programming languages syntax.

* Since it is language independent, it can be translated to any computer language code.

* It allows designer to express logic in plain natural language.

* It is easier to write actual code using pseudocode.

* Unlike algorithms, pseudocodes are concise so pseudocodes are more readable and easier to modify.

Explanation:

8 0
3 years ago
Victoria is creating a brochure for her photography studio. She designed the layout and placed a photo in the center of the page
cestrela7 [59]

Assuming Victoria is using Adobe Photoshop to create her brochure, below are the steps she is required to follow.

She should first open the image on Photoshop, click on the image option and select duplicate just in case the resized image is not what she wants.

Still on the image option, she should select Image size. A screen will pop up at this point, indicating the image’s current size. For the purposes of image resizing, Victoria should select Pixel dimensions category.

She should be able to type her preferred dimensions for both the width and height. She should make sure ‘Constrain Proportions’ is unchecked to be able to type in separate values.

If she decides to use the photo editing program, she can simply click on the image, and if resize handles appear around it, she can click and drag those to the desired size.


3 0
3 years ago
Other questions:
  • True or false? You can test your marketing emails in different email clients from within the email editor.
    10·1 answer
  • Which of the following would be considered a strong password?
    5·2 answers
  • Information is a valuable asset and not everyone in the world can be trusted with it. Therefore, we need to protect our valuable
    10·1 answer
  • The two ways to use the help menu is by searching of the contents or searching the _____
    13·2 answers
  • How do you change exposure to allow for greater DoF
    10·1 answer
  • Drag each label to the correct location on the image.
    10·1 answer
  • Write a program that asks the user for two file names. The first file will be opened for input and the second file will be opene
    8·1 answer
  • Sebutkan beberapa contoh peralatan komunikasi zaman dahulu beserta dengan keterangannya!
    14·1 answer
  • 4.12 LAB: Using math methods Given three floating-point numbers x, y, and z, output x to the power of z, x to the power of (y to
    10·1 answer
  • What is the difference between
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!