标签:
package homework;
import java.util.Scanner;
public class DayNum {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s = new Scanner(System.in); //创建一个输入对象
System.out.print("请输入年");
int year 年 = s.nextInt();//接收用户输入的数据。存在year
System.out.print("请输入月");
int month 月 = s.nextInt();//接收用户输入的数据。存在month
System.out.print("请输入日");
int day 日 = s.nextInt();//接收用户输入的数据。存在day
int twoDays = 28;
if((year%4==0 && year%100!=0) || year%400==0){
twoDays = 29;
}
int bigMonth = 31;
int middleMonth = 30;
int sum = 0;
if(month == 1){
sum+=day;//1月份只加天数
}else if(month ==2){
sum = bigMonth+day;
}else if(month == 3){
sum = bigMonth+twoDays+day;
}else if(month==4){
sum = bigMonth*2+twoDays+day;
}
System.out.print(sum);
}
}
标签:
原文地址:http://www.cnblogs.com/RunawayMama/p/5516684.html