Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the switch multiple-selection statement control statements to return the n

ID: 3678176 • Letter: U

Question

Using the switch multiple-selection statement control statements to return the number of days in a month. Each month will be represented by a corresponding integer (1 is January, 2 is February, ...12 is December). There should be separate cases for months with 30 days (September, April, June, and November), months with 31 days (January, March, May, July, August, October, December) and February is its own case. Note: You must address Leap Year calculations. Makes sure you address the formula in your Problem Specification.

Please help write this java code

Explanation / Answer

class Demo

{

public static void main(String args[]);

{

int month=2;

int year=2000;

int numDays=0;

switch(month)

{

case 1:

case 3:

case 5:

case 7:

case 8:

case 10:

case 12:

       numDays=31;

        if(month == 1)

        { System.out.println("Number of days in January is "+numDays);}

        elseif(month == 3)

          { System.out.println("Number of days in March is "+numDays);}

         elseif(month == 5)

         { System.out.println("Number of days in May is "+numDays);}

        elseif(month == 7)

         { System.out.println("Number of days in July is "+numDays);}

       elseif(month == 8)

{System.out.println("Number of days in Auguest"+numDays);}

elseif(month == 10)

{System.out.println("Number of days in October is "+numDays);}

elseif(month == 12)
{ System.out.println("Number of days in December is "+numDays);

}
break;

case 4:

case 6:

case 9:

case 11:

numDays=30;

      if(month == 4)

{System.out.println("Number of days in April is "+numDays);}

elseif(month ==6)

{System.out.println("Number of days in June is "+numDays);}

elseif(month == 9)
   {System.out.println("Number of days in September is "+numDays);}

elseif(month == 11)
   {System.out.println("Number of days in November is "+numDays);}
  
break;

case 2:

   if(((year%4 ==0)&&!(year %100 ==0)) || (year %400)==0))

      numDays=28;

     System.out.println(:Number of days inFebruary is"+numDays);

break;

default:

System.out.println("Invalid month");

break;

}

}

}