codedamn

Check if the given year is a leap year or not

Created by Piyush Garg about a year ago

0

No description provided

1 Comment

    0

    import java.util.Scanner;

    public class Main {

    public static void main(String args[]) { // Write your code here... Scanner scan =new Scanner(System.in); System.out.print("Input Year:"); int n = scan.nextInt();

    if(n%4 == 0){
      if(n%100 == 0){
        if(n%400 == 0){
          System.out.print("true");
        }else{
          System.out.print("false");
        }
      }else{
          System.out.print("true");
      }
    }else{
          System.out.print("false");
    }
    

    } } //This Also Works Fine /** ➜ code java Main Input Year:2000 true
    ➜ code java Main Input Year:1999 false
    ➜ code java Main Input Year:2024 true
    ➜ code java Main Input Year:1998 false */

    @pranshubasak

    Pranshu Basak

    @pranshubasak

Your comment