-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
63 lines (52 loc) · 2.19 KB
/
Main.java
File metadata and controls
63 lines (52 loc) · 2.19 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
56
57
58
59
60
61
62
63
public class Main {
public static void main(String[] args) {
System.out.println(printDayOfWeek(0));
System.out.println(printDayOfWeek(1));
System.out.println(printDayOfWeek(2));
System.out.println(printDayOfWeek(3));
System.out.println(printDayOfWeek(4));
System.out.println(printDayOfWeek(5));
System.out.println(printDayOfWeek(6));
System.out.println(printDayOfWeek(7));
System.out.println(printWeekDay(1));
System.out.println(printWeekDay(2));
System.out.println(printWeekDay(3));
System.out.println(printWeekDay(4));
System.out.println(printWeekDay(5));
System.out.println(printWeekDay(6));
System.out.println(printWeekDay(7));
}
public static String printDayOfWeek(int day){
return switch (day){
case 0 -> "Day " + day + " of the week -> Sunday";
case 1 -> "Day " + day + " of the week -> Monday";
case 2 -> "Day " + day + " of the week -> Tuesday";
case 3 -> "Day " + day + " of the week -> Wednesday";
case 4 -> "Day " + day + " of the week -> Thursday";
case 5 -> "Day " + day + " of the week -> Friday";
case 6 -> "Day " + day + " of the week -> Saturday";
default -> "Day " + day + " of the week -> Invalid Day";
};
}
public static String printWeekDay(int day){
String weekday = "";
if (day==0){
weekday = "Day " + day + " of the week -> Sunday";
} else if (day==1) {
weekday = "Day " + day + " of the week -> Monday";
}else if (day==2) {
weekday = "Day " + day + " of the week -> Tuesday";
}else if (day==3) {
weekday = "Day " + day + " of the week -> Wednesday";
}else if (day==4) {
weekday = "Day " + day + " of the week -> Thursday";
}else if (day==5) {
weekday = "Day " + day + " of the week -> Friday";
}else if (day==6) {
weekday = "Day " + day + " of the week -> Saturday";
}else if (day==7) {
weekday = "Day " + day + " of the week -> Invalid Day";
}
return weekday;
}
}