Given a year, find if it is a leap year.
A Leap year is the year that is multiple of 4. But, multiples of 100 which are not multiples of 400 are not leap years.
User Task:
Input consists of the year value as an int. You need to print 1 in case of leap year and 0 otherwise.
Solution of Leap Year :–
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
public static void main (String[] args) throws java.lang.Exception
{
//your code here
Scanner scanner = new Scanner(System.in);
int year = scanner.nextInt();
if(year%4==0)
{
if(year%100==0)
{
if(year%400==0)
{
System.out.println("1");
}
else{
System.out.println("0");
}
}
else{
System.out.println("1");
}
}
else{
System.out.println("0");
}
}
}
Add a Comment