zoukankan      html  css  js  c++  java
  • Java 判断某一天是这一年的第几天

    package Day8_06;
    
    import java.util.*;
    
    public class ClassTest {
        public static void main(String[] args) {
            System.out.print("请输入年:");
            Scanner s1 = new Scanner(System.in);
            int Year = s1.nextInt();
            System.out.print("请输入月:");
            Scanner s2 = new Scanner(System.in);
            int Mon = s2.nextInt();
            System.out.print("请输入日:");
            Scanner s3 = new Scanner(System.in);
            int Day = s3.nextInt();
            int sum = 0;
            
            switch(Mon){
                case 12:sum += 30;
                case 11:sum += 31;
                case 10:sum += 30;
                case 9 :sum += 31;
                case 8 :sum += 31;
                case 7 :sum += 30;
                case 6 :sum += 31;
                case 5 :sum += 30;
                case 4 :sum += 31;
                case 3 :
                    if((Year % 4 == 0 && Year % 100 != 0) || (Year % 100 == 0 && Year % 400 == 0)){
                        System.out.println("这一年是闰年!");
                        sum += 29;
                    }
                    else{
                        System.out.println("这一年是平年!");
                        sum += 28;
                    }
                case 2 :sum += 31;
                case 1 :sum += Day;
            }
            System.out.println(Year + "年" + Mon + "月" + Day + "日,是这一年的第:" + sum + "天");
        }
    }
  • 相关阅读:
    多线程
    ERP概念介绍
    Servlet生命周期
    springmvc工作流程
    spring事务管理的接口
    解决主从备份Slave_SQL_Running:No
    实现Mysql主从备份
    springboot集成mybatis进行开发
    SpringBoot 入门第一章
    Hibernate 关联关系映射
  • 原文地址:https://www.cnblogs.com/chuijingjing/p/9429076.html
Copyright © 2011-2022 走看看