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."); + } +}