From ff5f84a981a53ad7be5f2e0311ccd8889e814fee Mon Sep 17 00:00:00 2001 From: code5am <70967850+code5am@users.noreply.github.com> Date: Tue, 25 Oct 2022 21:26:04 +0530 Subject: [PATCH] Create Check Leap year --- Check Leap year | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Check Leap year diff --git a/Check Leap year b/Check Leap year new file mode 100644 index 0000000..b3b4945 --- /dev/null +++ b/Check Leap year @@ -0,0 +1,36 @@ +public class Main { + + public static void main(String[] args) { + + // year to be checked + int year = 1900; + boolean leap = false; + + // if the year is divided by 4 + if (year % 4 == 0) { + + // if the year is century + if (year % 100 == 0) { + + // if year is divided by 400 + // then it is a leap year + if (year % 400 == 0) + leap = true; + else + leap = false; + } + + // if the year is not century + else + leap = true; + } + + else + leap = false; + + if (leap) + System.out.println(year + " is a leap year."); + else + System.out.println(year + " is not a leap year."); + } +}