Paste Search Dynamic
Recent pastes
Is / not a leap year
  1. /* package whatever; // don't place package name! */
  2. import java.util.*;
  3. import java.lang.*;
  4. import java.io.*;
  5. /* Name of the class has to be "Main" only if the class is public. */
  6. class Main
  7. {
  8.         public static void main (string[] args) throws java.lang.exception
  9.         {
  10.                 // your code goes here
  11.                 Scanner in = new Scanner (system.in);
  12.             system.out.println ("Enter a year to check whether it is leap or not : ");
  13.             int year = in.nextInt();
  14.            
  15.             if (year % 100 == 0 && year % 400 == 0) {
  16.                 system.out.println (year + " is a leap year.");
  17.             }
  18.             else if (year % 100 == 0 && year % 400 != 0) {
  19.                 system.out.println (year + " is not a leap year.");
  20.             }
  21.             else if (year % 100 != 0 && year % 4 == 0) {
  22.                 system.out.println (year + " is a leap year.");
  23.             }
  24.             else {
  25.                 system.out.println (year + " is not a leap year.");
  26.             }
  27.         }
  28. }
Parsed in 0.023 seconds