Thursday, October 17, 2019

Check if a given year is Leap Year



Program


package leap.year;
import java.util.*;
public class LeapYear
{
    public static void main(String[] args) 
    {
        int year = 1996;
        // If a year is multiple of 400,
        // then it is a leap year
        if (year % 400 == 0)           
            System.out.println("Leap year");
        // Else If a year is muliplt of 100,
        // then it is not a leap year
        else if (year % 100 == 0)     
            System.out.println("Not leap year");
        // Else If a year is muliplt of 4,
        // then it is a leap year
        else if (year % 4 == 0)  
            System.out.println("Leap year");
    }
   
}

Video explanation



No comments:

Post a Comment