{"id":1382,"date":"2022-03-03T19:11:36","date_gmt":"2022-03-03T19:11:36","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=1382"},"modified":"2022-03-03T19:11:36","modified_gmt":"2022-03-03T19:11:36","slug":"program-to-check-leap-year","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/03\/03\/program-to-check-leap-year\/","title":{"rendered":"Program to check Leap Year"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">&nbsp;Program to check whether the input year is leap or not<\/h4>\n\n\n\n<p>Here we are using\u00a0<strong>Scanner class<\/strong>\u00a0to get the input from user and then we are using if-else statements to write the logic to check leap year. To understand this program, you should have the knowledge of following concepts of\u00a0Core Java Tutorial:<br>\u2192\u00a0If-else statement<br>\u2192\u00a0Read input number in Java program<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.Scanner;\npublic class Demo {\n\n    public static void main(String&#91;] args) {\n\n    \tint year;\n    \tScanner scan = new Scanner(System.in);\n    \tSystem.out.println(\"Enter any Year:\");\n    \tyear = scan.nextInt();\n    \tscan.close();\n        boolean isLeap = false;\n\n        if(year % 4 == 0)\n        {\n            if( year % 100 == 0)\n            {\n                if ( year % 400 == 0)\n                    isLeap = true;\n                else\n                    isLeap = false;\n            }\n            else\n                isLeap = true;\n        }\n        else {\n            isLeap = false;\n        }\n\n        if(isLeap==true)\n            System.out.println(year + \" is a Leap Year.\");\n        else\n            System.out.println(year + \" is not a Leap Year.\");\n    }\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter any Year: \n2001\n2001 is not a Leap Year.<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;Program to check whether the input year is leap or not Here we are using\u00a0Scanner class\u00a0to get the input from user and then we are using if-else statements to write the logic to check leap year. To understand this program, you should have the knowledge of following concepts of\u00a0Core Java Tutorial:\u2192\u00a0If-else statement\u2192\u00a0Read input number in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[260],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1382"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=1382"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1382\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=1382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=1382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=1382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}