利用Java判断年份是否为闰年

首页 / 编程代码 / 正文
    package billjobs;
    import java.util.Scanner;
    public class jack {
    
        public static void main(String[] args) {
               Scanner scan=new Scanner(System.in);//打开扫描仪
               System.out.print("Plese input the year:");
               int year=scan.nextInt();
               if(year%4==0 && year%100!=0){
                  System.out.print("Congratulation! It's the leap year!");
               }else 
               if(year%400==0){
                   System.out.print("Congratulation! It's the leap year!");
               }else
               {
                   System.out.print("Sorry,It's not the leap year.");
               }   
               scan.close();
        }
    }
打赏
评论区
头像