Sunday, June 7, 2020

Write a program to input a number and check whether it is Leap Year or not?

16)  Write a program in java to input a number and check whether it is Leap Year or not?( A year contain 366 days called leap year, century year divided by 400 and normal year divided by 4)

import java.util.*;
public class Leap_year_5
{
   public static void main(String args[ ])
    {
        Scanner sc = new Scanner (System.in);
        System.out.println("Enter a year");
        int a = sc.nextInt();
        if(a%4==0||a%400==0)
        {
            System.out.println(a+" is a leap year");
        }
        else
        {
            System.out.println(a+" is not a leap year");
        }
    }
}

No comments:

Post a Comment

if you have any doubts, Please let me know.
Your Truly
Shashank Porwal

 jhvghvgk ;nkjn ,nkjhj