This Java program checks whether a given year is a leap year or not.
import java.util.Scanner; class Leap_Year { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the Year :"); int year = input.nextInt(); boolean flag = false; if(year % 400 == 0) flag = true; else if (year % 100 == 0) flag = false; else if(year % 4 == 0) flag = true; else flag = false; if(flag) { System.out.println("Year "+year+" is a Leap Year"); } else { System.out.println("Year "+year+" is not a Leap Year"); } } }
Enter the Year :2000 Year 2000 is a Leap Year
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions