forked from bliblidotcom/training-java-future-program
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDayCount.java
More file actions
Latest commit
42 lines (42 loc) · 1.29 KB
/
Copy pathDayCount.java
File metadata and controls
42 lines (42 loc) · 1.29 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
publicclassDayCount{
publicstaticvoidmain(String[] args){
if(args.length != 2){
System.out.println("Usage: dayCount <monthNum yearNum>");
return;
}
intmonth = Integer.parseInt(args[0]);
intyear = Integer.parseInt(args[1]);
intdays = 0;
switch(month){
case1:
case3:
case5:
case7:
case8:
case10:
case12:
days = 31;
break;
case4:
case6:
case9:
case11:
days = 30;
break;
case2:
switch(year%4){
case0:
days = 29;
break;
default:
days = 28;
break;
}
break;
default:
System.out.println("Tanggal Tidak Valid");
break;
}
System.out.println("Jumlah hari adalah " + days + " hari");
}
}