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
private static int getSumDays(int year, int month, int day) {
int dayss = 0;
//先把{1,month) 之间整月的天数进行累加,即把1月到8月整月的天数累加
for(int m =1; m < month; m++){
days