Computer Science, asked by aqibshaikh419, 1 month ago

Write a program to assign the sequence number of a month and display the name of the month and the number of days in the given month. [15]
Example:
ASSIGNED VALUE: 5
OUTPUT
MAY – 31 DAYS

Answers

Answered by ItzMeSam35
2

import java.util.*;

public class Months

{

public static void main(String args[])

{

Scanner sc=new Scanner (System.in);

System.out.println("Please Enter The Month Number");

int Month = sc.nextInt();

if (Month == 1)

{

System.out.println("JANUARY - 31 DAYS");

}

else if (Month == 2)

{

System.out.println("FEBRUARY - 28 DAYS");

}

else if (Month == 3)

{

System.out.println("MARCH - 31 DAYS");

}

else if (Month == 4)

{

System.out.println("APRIL - 30 DAYS");

}

else if (Month == 5)

{

System.out.println("MAY - 31 DAYS");

}

else if (Month == 6)

{

System.out.println("JUNE - 30 DAYS");

}

else if (Month == 7)

{

System.out.println("JULY - 31 DAYS");

}

else if (Month == 8)

{

System.out.println("AUGUST - 31 DAYS");

}

else if (Month == 9)

{

System.out.println("SEPTEMBER - 30 DAYS");

}

else if (Month == 10)

{

System.out.println("OCTOBER - 31 DAYS");

}

else if (Month == 11)

{

System.out.println("NOVEMBER - 30 DAYS");

}

else if (Month == 12)

{

System.out.println("DECEMBER - 31 DAYS");

}

else

{

System.out.println("INVALID MONTH NUMBER ENTERED");

}

sc.close();

}

}

Similar questions