Java Code for calculating Leap Year

前端 未结 20 2260
执念已碎
执念已碎 2020-11-22 16:30

I am following \"The Art and Science of Java\" book and it shows how to calculate a leap year. The book uses ACM Java Task Force\'s library.

Here is the code the boo

20条回答
  •  北海茫月
    2020-11-22 17:13

    easiest way ta make java leap year and more clear to understandenter code here

    import  java.util.Scanner;
    

    class que19{

    public static void main(String[] args) {
    
        Scanner input=new Scanner(System.in);
    
        double a;
    
        System.out.println("enter the year here ");
        a=input.nextDouble();
        if ((a % 4 ==0 ) && (a%100!=0) || (a%400==0)) {
            System.out.println("leep year");
    
        }
        else {
            System.out.println("not a leap year");
        }
    }
    

    }

提交回复
热议问题