- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise18.java
More file actions
Latest commit
26 lines (22 loc) · 612 Bytes
/
Copy pathExercise18.java
File metadata and controls
26 lines (22 loc) · 612 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
// The following program has many bugs. Fix them all.
PublicstaticvoidMain(String[] args) { // Find the errors!
intmo = Integer.parseInteger(arg[0]);
intyr = Integer.parseInteger(args[2]);
intdays = uninitialized;
switch {
case9: case4:
case6: case11:
intdays = 31;
case1: case3: case5: case7:
case8: case10: case12:
intdays = 30;
else:
if ((year % 4 == 0) && !(year % 100 == 0 &&
year % 400 != 0))
intdays = 29; /* hurray, leapyear!!
else
intdays = 28;
}
System.Println("In year"+yr+" month "+mo+" has "+
days + " days");
}