-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdayofyear.java
More file actions
55 lines (54 loc) · 1.15 KB
/
dayofyear.java
File metadata and controls
55 lines (54 loc) · 1.15 KB
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
45
46
47
48
49
50
51
52
53
54
55
import java.util.Scanner;
public class dayofyear {
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 date=scan.nextInt();
int dayofyear=0;
switch(month){
case 1:
dayofyear=date;
break;
case 2:
dayofyear=31+date;
break;
case 3:
dayofyear=28+31+date;
break;
case 4:
dayofyear=28+31+31+date;
break;
case 5:
dayofyear=28+31+31+30+date;
break;
case 6:
dayofyear=28+31+31+30+31+date;
break;
case 7:
dayofyear=28+31+31+30+31+30+date;
break;
case 8:
dayofyear=28+31+31+30+31+30+31+date;
break;
case 9:
dayofyear=28+31+31+30+31+30+31+31+date;
break;
case 10:
dayofyear=28+31+31+30+31+30+31+31+30+date;
break;
case 11:
dayofyear=28+31+31+30+31+30+31+31+30+31+date;
break;
case 12:
dayofyear=28+31+31+30+31+30+31+31+30+31+30+date;
break;
default:
System.out.println("对不起你的输入有误");
}
System.out.println(year+"年"+month+"月"+date+"日是当年当中的第"+dayofyear+"天");
}
}