Computer Science, asked by vihangaravishka30, 1 month ago

Write a single Java program to perform the following.

1. Read an year and a month.
2. Display the number of days in the particular month. (Hint - you should consider the Leap year as well)​

Answers

Answered by vaishnavipatel2209
1

Answer:

import java.util.*;

public class Main

{

public static void main(String[] args)

{

 int year, month;

 Scanner sc = new Scanner(System.in);

 month = sc.nextInt();

 year = sc.nextInt();

 if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)

  System.out.print("Number of days is 31");

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

 {

  System.out.print("Number of days is 29");

 }

 else if(month == 2)

 {

  System.out.print("Number of days is 28");

 }

 else

  System.out.println("Number of days is 30");

}

}

Explanation:

hope this would help !!

if you find it helpful do rate it as brainliest!:)

Similar questions