-
Notifications
You must be signed in to change notification settings - Fork 1
/
TwelveDaysChristmas.java
139 lines (108 loc) · 3.33 KB
/
TwelveDaysChristmas.java
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// Muhammad Naveed
// 20 - Arid - 348
// https://www.github.com/uxlabspk/JavaCodes/
public class TwelveDaysChristmas
{
// static variable
private static String result = "";
// static method
public static void songLyrics()
{
// main loop for iterating
for (int day = 1; day < 13; day++)
{
// appending the song lyrics
result += "\nOn the ";
// main switch for appending first, second, third, etc.
switch (day)
{
case 1:
result += "first";
break;
case 2:
result += "second";
break;
case 3:
result += "third";
break;
case 4:
result += "fourth";
break;
case 5:
result += "fifth";
break;
case 6:
result += "sixth";
break;
case 7:
result += "seventh";
break;
case 8:
result += "eight";
break;
case 9:
result += "ninth";
break;
case 10:
result += "tenth";
break;
case 11:
result += "eleventh";
break;
case 12:
result += "twelvth";
break;
}
// appending song lyrics
result += " day of Christmas my true love gave to me ";
// switch for appending song lyrics
switch(day)
{
case 1:
result += "a Patridge in a pear tree";
break;
case 2:
result += "Two turtle doves";
break;
case 3:
result += "Three french hens";
break;
case 4:
result += "Four calling birds";
break;
case 5:
result += "Five golden rings";
break;
case 6:
result += "Six geese-a-laying";
break;
case 7:
result += "Seven swans-a-swimming";
break;
case 8:
result += "Eight maids-a-milking";
break;
case 9:
result += "Nine ladies dancing";
break;
case 10:
result += "Ten drummers drumming";
break;
case 11:
result += "Eleven pipers piping";
break;
case 12:
result += "Twelve Lords-a-leaping";
break;
}
// showing the song lyrics
System.out.println(result);
}
}
// main driven function
public static void main(String[] args)
{
// calling static method
songLyrics();
}
}