-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTwelveDays.java
137 lines (89 loc) · 2.46 KB
/
TwelveDays.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
package a1_TwelveDays;
/*
Alistair Godwin
SID: 020079158
UID: agodwin
Prof: Mehrnaz Zhian
A1 - Question 5: Twelve Days of Christmas
This program uses switch statements and method calls to print out the lyrics to the twelve days of Christmas
*/
public class TwelveDays {
public static void main(String[] args) {
System.out.println("======Assignment 1: Question 5: Twelve Days of Chirstmas.=====\n\n");
//Go through each listed day.
for(int i = 1; i < 13; i++){
System.out.printf("\nOn the %s day of Chirstmas, my true love sent to me\n",GetDayOf(i));
//Go reverse order through the days items starting from i.
for(int j = i; j > 0; j--){
// AND <--- a partridge in a pear tree! Multi items need 'and' for last item
if(j == 1 && i != 1) System.out.printf("and %s\n",GetItem(j));
else{
System.out.printf("%s\n",GetItem(j)); //a partridge in a pear tree!
}
}
}
System.out.println("\nGoodbye!");
}
//Return the Day requested from the incoming int.
public static String GetDayOf(int Day){
switch (Day){
case 1:
return "First";
case 2:
return "Second";
case 3:
return "Third";
case 4:
return "Fourth";
case 5:
return "Fifth";
case 6:
return "Sixth";
case 7:
return "Seventh";
case 8:
return "Eight";
case 9:
return "Ninth";
case 10:
return "Tenth";
case 11:
return "Eleventh";
case 12:
return "Twelvth";
default:
return "ERROR: Out of Bounds Int Recieved in Method GetDayOF";
}
}
//Return the Item requested from the incoming int.
public static String GetItem(int Day){
switch (Day){
case 1:
return "a Partridge in a Pear Tree.";
case 2:
return "Two Turtle Doves,";
case 3:
return "Three French Hens,";
case 4:
return "Four Calling Birds,";
case 5:
return "Five Gold Rings,";
case 6:
return "Six Geese a-Laying,";
case 7:
return "Seven Swans a-Swimming,";
case 8:
return "Eight Maids a-Milking,";
case 9:
return "Nine Ladies Dancing,";
case 10:
return "Ten Lords a-Leaping,";
case 11:
return "Eleven Pipers Piping,";
case 12:
return "Twelve Drummers Drumming,";
default:
return "ERROR: Out of Bounds Int Recieved in Method GetItem";
}
}
}