public class Christmas2 { public static void main(String[] args) { String[] gift = { null, // 0 null, // 1 "Two turtledoves", // 2 "Three French hens", // 3 "Four colly birds", // 4 "Five golden rings", // 5 "Six geese a-laying", // 6 "Seven swans a-swimming", // 7 "Eight maids a-milking", // 8 "Nine ladies dancing", // 9 "Ten lords a-leaping", //10 "Eleven pipers piping", //11 "Twelve drummers drumming" //12 }; String[] suffix = { null, "st", "nd", "rd", "th" //for all numbers >= 4; use Math.min }; for (int day = 1; day <= 12; ++day) { System.out.print("On the " + day); System.out.print(suffix[Math.min(day, 4)]); System.out.println(" day of Christmas"); System.out.println("My true love gave to me"); for (int d = day; d > 1; --d) { System.out.println(gift[d]); } System.out.print(day == 1 ? "A" : "And a"); System.out.println(" partridge in a pair tree."); if (day < 12) { System.out.println(); } } System.exit(0); } }