/*
编写程序:从键盘输入2019年的”month“和”day“,要求通过程序输出输入的日期是2019年的第几天。
举例:
2,15 : 31 + 15;
5,7 :31 + 28 + 31 +30 + 7
...
*/
import java.util.Scanner;
class SwitchCaseTest2{
public static void main(String[] args) {
System.out.println("--SwitchCaseTest2--");
Scanner scanner = new Scanner(System.in);
System.out.println("请输入month:");
int month = scanner.nextInt();
System.out.println("请输入day:");
int day = scanner.nextInt();
System.out.println("month = " + month + ",day = " + day);
int number = 0;
switch (month){
case 12:
number += 30;
case 11:
number += 31;
case 10:
number += 30;
case 9:
number += 31;
case 8:
number += 31;
case 7:
number += 30;
case 6:
number += 31;
case 5:
number += 30;
case 4:
number += 31;
case 3:
number += 28;
case 2:
number += 31;
case 1:
number += day;
}
System.out.println("是第 " + number + " 天");
}
}
网友评论