java源代码实现判断闰年和平年

package net.xsp.lesson04;

import java.util.Scanner;

/**

  • 功能:判断闰年

  • 作者:Stranger_top

  • 日期:2019年3月21日
    */
    public class JudgeLeapYear {
    public static void main(String[] args) {
    // 声明部分
    int year;
    Scanner sc = new Scanner(System.in);

     // 输入部分
     System.out.print("year = ");
     year = sc.nextInt();
    
     // 处理部分 + 输出部分
     if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0){
         System.out.println(year + "是闰年。");
     }else {
         System.out.println(year + "是平年。");
     }
    

    }
    }

猜你喜欢

转载自blog.csdn.net/Stranger_top/article/details/88838292