zoukankan      html  css  js  c++  java
  • 判断输入的年份是闰年还是平年!!!

    package com.hp.cn1;

    import java.util.Scanner;

    //年份能被4整除闰年
    //年份能被100整除不是闰年
    //年份能被400整除闰年
    public class Task2 {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            System.out.println("---->请输入年份");
            int year  = sc.nextInt();
            System.out.println("你输入的年份是"+year);
            
            if(year % 100 == 0) {
                if(year % 400 == 0) {
                    System.out.println(year + "是闰年");
                }else {
                    System.out.println(year + "不是闰年");
                }
            }else {
                if(year % 4 == 0) {
                    System.out.println(year + "是闰年");
                }else {
                    System.out.println(year + "不是闰年");
                }
            }
        }
    }

  • 相关阅读:
    Spark SQL ---一般有用
    idea快捷键
    04.Scala编程实战 ---没看
    03.Scala高级特性 ---没看
    02.Actor编程 ---没看
    01.Scala编程基础 ---没看
    附6、Storm面试题目答疑 ---一般有用
    扩展运算符
    ES6新增数组方法(部分)
    for of 循环
  • 原文地址:https://www.cnblogs.com/wjwz/p/14131861.html
Copyright © 2011-2022 走看看