forked from angiejones/java-programming
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMonth.java
More file actions
41 lines (37 loc) · 1.2 KB
/
Copy pathMonth.java
File metadata and controls
41 lines (37 loc) · 1.2 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
package chapter6;
public class Month {
public static String getMonth(int month){
switch(month){
case 1: return "January";
case 2: return "February";
case 3: return "March";
case 4: return "April";
case 5: return "May";
case 6: return "June";
case 7: return "July";
case 8: return "August";
case 9: return "September";
case 10: return "October";
case 11: return "November";
case 12: return "December";
default: return "Invalid month. Please enter a value between 1 and 12.";
}
}
public static int getMonth(String month){
switch(month){
case "January": return 1;
case "February": return 2;
case "March": return 3;
case "April": return 4;
case "May": return 5;
case "June": return 6;
case "July": return 7;
case "August": return 8;
case "September": return 9;
case "October": return 10;
case "November": return 11;
case "December": return 12;
default: return -1;
}
}
}