Find Out Leap Year by using Java Program
Code:
import java.util.Scanner;
public class LeapYear
{
public static void main(String[] args)
{
int y;
Scanner sc = new Scanner(System.in);
System.out.print("\nEnter The Year : ");
y = sc.nextInt();
if(y%400 == 0)
System.out.println("\n"+y+" Is Leap Year\n");
else if(y%4 == 0 && y%100 != 0)
System.out.println("\n"+y+" Is Leap Year\n");
else
System.out.println("\n"+y+" Is Not Leap Year\n");
}
}
Output of program:
import java.util.Scanner;
public class LeapYear
{
public static void main(String[] args)
{
int y;
Scanner sc = new Scanner(System.in);
System.out.print("\nEnter The Year : ");
y = sc.nextInt();
if(y%400 == 0)
System.out.println("\n"+y+" Is Leap Year\n");
else if(y%4 == 0 && y%100 != 0)
System.out.println("\n"+y+" Is Leap Year\n");
else
System.out.println("\n"+y+" Is Not Leap Year\n");
}
}
Output of program:
No comments