"Year is a leap year or not" JAVA code by Naymul Islam CSE 18 PCIU


Code: 

import java.util.Scanner;

public class LeapYear {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);

        System.out.println("Input the year: ");

        int year = sc.nextInt();

        boolean x = (year % 4) == 0;

        boolean y = (year % 100) != 0;

        boolean z = ((year % 100 == 0) && (year % 400 == 0));


        if (x && (y || z)) {

            System.out.println(year + " is a leap year");

        } else {

            System.out.println(year + " is not a leap year");

        }

    }

}


 import java.util.Scanner;


public class LeapYear {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        System.out.println("Input the year: ");
        int year = sc.nextInt();
        boolean x = (year % 4) == 0;
        boolean y = (year % 100) != 0;
        boolean z = ((year % 100 == 0) && (year % 400 == 0));

        if (x && (y || z)) {
            System.out.println(year + " is a leap year");
        } else {
            System.out.println(year + " is not a leap year");
        }
    }
}

                                                                                                                                        

No comments:

Post a Comment

Max Sub Array Sum: Kadane's Algorithm

Code of: Max Sub Array Sum: Kadane's Algorithm. public class MaxSubArraySumKadanesALgorithm {     public static void Kadane ( int ...