Question: Write a Java program that prints the verses of the song The Twelve days of Christmas in which each verse adds one line. The user

Write a Java program that prints the verses of the song The Twelve days of Christmas in which each verse adds one line. The user should enter one of the twelve days and the code should output the song, starting from the first verse. Here is the final verse for reference: On the 12th day of Christmas, my true love gave to me Twelve drummers drumming, Eleven pipers piping, Ten lords a-leaping, Nine ladies dancing, Eight maids a-milking, Seven swans a-swimming, Six geese a-laying, Five golden rings, Four calling birds, Three French hens, Two turtle doves, and A partridge in a pear tree. You will need: 1. A Scanner object and a variable to store the day entered 2. A while loop for input validation. The user should ONLY be able to enter a day between 1 and 12. 3. A second while loop to output the verses. a. In this loop you will use two switch statements. i. The first switch statement should add the appropriate suffix to the day. (Day 1 should be 1st, day 2 should be 2nd, day 3 should be 3rd, and all other days should end with th. ) ii. The second switch statement should output the gift for the particular day. You should utilize the fall through method for this switch statement (in order words, dont use the break statement in this one.) Please stick to the format shown in the final verse and in the sample output. All gifts should appear on a new line.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!