package com.bjpowernode.chapter01.homework.p1;
import java.time.Month;
import java.util.Scanner;
/*
* 3) 编译程序,从键盘上输入年月日,打印该日期对应这一年的第几天,如:
* 输入:
* 2018 1 5
* 输出:
* 2018-1-5是2018年的第5天
* 输入:
* 2018 2 5
* 输出:
* 2018-2-5是2018年的第36天
* 输入:
* 2018 3 5
* 输出:
* 2018-3-5是2018年的第64天
*
*
*
*/
public class Test {
public static void main(String[] args){
//1)从键盘上输入年月日
Scanner sc = new Scanner(System.in);
System.out.println("请输入年 月 日 ");
int year = sc.nextInt();
int month = sc.nextInt();
int day = sc.nextInt();
//2)计算日期对应这一年的第几天
int sumdays = getSumDays(year,month,day);
//3)打印该日期对应这一年的第几天
System.out.println(year+"年" + month + "月" + day + "日,是" + year + "年的第" + sumdays +"天");
}
// 计算 year-month-day日期对应year这一年的第几天 2018 9 10
javaSE-第167篇-根据输入日期计算这一年的第几天
最新推荐文章于 2021-12-14 13:33:07 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)