java提示用户输入年月日信息,判断这一天是这一年中的第几天并打印
import java.util.Scanner;
public class UserInJudgeTest{
public static void main(String[] args){
System.out.println("请输入一次输入提示信息:");
System.out.println("强输入你要查询的年份 例如 1997");
Scanner sc = new Scanner(System.in);
int year = sc.nextInt();
System.out.println("强输入你要查询的月份 例如 7");
int mon = sc.nextInt();
System.out.println("强输入你要查询的日 例如 1");
int day = sc.nextInt();
int[] monthDay = {31, 27, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0){
monthDay[1] = 28;
}
int res = 0;
for(int i = 0; i < mon - 1; i++) {
res += monthDay[i];
}
res += day;
System.out.println(year + "年" + mon + "月" + day +"日" + "是" + res + "天");
}
}