Code:
import java.util.Scanner;class leap
{
public static void main(String[] args)
{
int a;
Scanner in=new Scanner(System.in);
System.out.print("Enter the year to check leap or not : ");
a=in.nextInt();
if ((a%4==0)&&(a%100!=0))
{
System.out.println(a+" is a leap year");
}
else if ((a%4==0)&&(a%100==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