From 2d2eaff1dbc3a63cdf2ded3c019fe6232208ccb8 Mon Sep 17 00:00:00 2001 From: sonam290597 <73711739+sonam290597@users.noreply.github.com> Date: Fri, 30 Oct 2020 23:55:12 +0530 Subject: [PATCH] Create Check entered year is leap year or not. Java program to check leap year. --- Check entered year is leap year or not. | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Check entered year is leap year or not. diff --git a/Check entered year is leap year or not. b/Check entered year is leap year or not. new file mode 100644 index 0000000..f17f018 --- /dev/null +++ b/Check entered year is leap year or not. @@ -0,0 +1,34 @@ +import java.util.Scanner; +public class Demo { + + public static void main(String[] args) { + + int year; + Scanner scan = new Scanner(System.in); + System.out.println("Enter any Year:"); + year = scan.nextInt(); + scan.close(); + boolean isLeap = false; + + if(year % 4 == 0) + { + if( year % 100 == 0) + { + if ( year % 400 == 0) + isLeap = true; + else + isLeap = false; + } + else + isLeap = true; + } + else { + isLeap = false; + } + + if(isLeap==true) + System.out.println(year + " is a Leap Year."); + else + System.out.println(year + " is not a Leap Year."); + } +}