Posts

Showing posts with the label leap year

Java program to check whether a year is leap or not

import java.util.*; class leapYear {     public static void main(String s[])     {         Scanner sc = new Scanner(System.in);         System.out.println("Enter a year to check whether it is leap year or not: ");         int yr= sc.nextInt();         if((yr % 4 == 0) && (yr % 100 == 0) && (yr % 400 == 0))         {             System.out.println("The year "+yr+" is a leap year.");         }         else         {             System.out.println("The year "+yr+" is not a leap year.");         }     } }