package experencetext;
import java.util.Scanner;
/**

  • @version 1.0
  • @Description TODO
  • @Author scar
  • @Date 2020/12/26 10:29
  • 判断是否是闰年
  • 判断闰年条件:
  • 1.普通年份 可以被4整除 但不可以被100整除的年份 为闰年
  • 2.整的世纪年 可以被400整除即 为闰年
    */
public class LeapYear {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in); 
        while (true) {
            System.out.println("请输入年份:");
            //接收输入的数据:
            int a = sc.nextInt();
            //如果输入-1,跳出查询
            if (a == -1) {
                break;
            }
            //调用方法 判断是否为闰年
            LeapYear(a);
        }
    }
    public static void LeapYear(int year) {
        if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
            System.out.println(year + "是闰年!");
        } else {
            System.out.println(year + "不是闰年!");
        }
    }
}

posted on 2020-12-26 11:42  剑舞红颜笑i  阅读(157)  评论(0)    收藏  举报