//从键盘上输入2016的month和day,要求通过程序输出输入的日期为2016年的第几天
import java.util.*;
class Alhh{
public static void main(String[] args){
Scanner in=new Scanner(System.in);
System.out.println("请输入月份:");
int month=in.nextInt();
System.out.println("请输入日期:");
int day=in.nextInt();
int sum=0;//用来记录month月day日是2016的第几天
switch(month){
case 12:
sum+=30;//十一月份的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:
sum+=29;
case 2:
sum+=31;
case 1:
sum+=day;
}
System.out.println(sum);
}
}
时间: 2024-10-13 12:14:19