forked from theManToBe/Java_Group9
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIfTest.java
More file actions
44 lines (43 loc) · 865 Bytes
/
IfTest.java
File metadata and controls
44 lines (43 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import java.util. Scanner;
class IfTest{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
System.out.println("请输入年");
int year = scan. nextInt();
System.out.println("请输入月");
int month = scan. nextInt();
System.out.println("请输入日");
int day = scan. nextInt();
int sumdays= 0;
switch (month ) {
case 12 :
sumdays += 30;
case 11 :
sumdays += 31;
case 10 :
sumdays += 30;
case 9 :
sumdays += 31;
case 8 :
sumdays += 31;
case 7 :
sumdays += 30;
case 6 :
sumdays += 31;
case 5 :
sumdays += 30;
case 4 :
sumdays += 30;
case 3 :
if (year % 400 == 0){
sumdays += 29;
} else
{sumdays += 28;}
case 2 :
sumdays += 31;
case 1 :
sumdays += day;
}
System.out.println(year +"年" + month + "月" + day + "日" + "是" + sumdays + "天");
}
}