Advertisement
AnindyaBiswas

Leap Year

Apr 27th, 2022
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Leap {
  3.     static boolean LeapYear(int yr)
  4.     {
  5.         if(yr % 400 == 0)
  6.             return true;
  7.         if(yr % 100 == 0)
  8.             return false;
  9.         if(yr % 4 == 0)
  10.             return true;
  11.         return false;
  12.     }
  13.     public static void main(String args[])
  14.     {
  15.         Scanner sc = new Scanner(System.in);
  16.         System.out.print("Enter the year : ");
  17.         int year = sc.nextInt();
  18.  
  19.         if(LeapYear(year))
  20.             System.out.print(year + " is a Leap Year!");
  21.         else
  22.             System.out.print(year + " is not a Leap Year!");
  23.     }
  24.    
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement