Program to check given year is leap year or not in java.

                           program

import java.util.*;

class Ved {

public static void main(String[] args) {

 Scanner sc = new Scanner(System.in);

 System.out.print("Enter the year= ");

 int y = sc.nextInt();

if ((y % 400 == 0) || (y % 4 == 0 && y % 100 != 0){

       System.out.println("Leap year");

} else {

            System.out.println("Not a leap year");

   }

 }

}

■》Output->

Enter the year= 1700

Not a leap year

Comments

Popular posts from this blog

Introduction of java Programming language.

Stack data structure.