# Thread: If/Else Switch Case problem

1. ## If/Else Switch Case problem

Hello! My brother recommended this site to me, he seemed to learn a lot from here. I'm working on If/Else statements for a class, and I thought I had it down until I was thrown this curve ball.

"Create an application that prints the verses of the song “The Twelve Days of Christmas”, in which the user enters the day (1-12) and each verse is printed. Use switch/case statements to break each pick into the verse. Also, make sure to use the “default” with the case statements if the user types an invalid number. On the twelfth day of Christmas, my true love sent to me, Twelve drummers drumming,
On the eleventh day of Christmas, my true love sent to me, Eleven pipers piping,
On the tenth day of Christmas, my true love sent to me, Ten lords a-leaping,
On the ninth day of Christmas, my true love sent to me, Nine ladies dancing,
On the eighth day of Christmas, my true love sent to me, Eight maids a-milking,
On the seventh day of Christmas, my true love sent to me, Seven swans a-swimming,
On the sixth day of Christmas, my true love sent to me, Six geese a-laying,
On the fifth day of Christmas, my true love sent to me, Five golden rings,
On the fourth day of Christmas, my true love sent to me, Four calling birds,
On the third day of Christmas, my true love sent to me, Three French hens,
On the second day of Christmas, my true love sent to me, Two turtle doves,
On the first day of Christmas, my true love sent to me, A partridge in a pear tree.

By the way, when a user hits 5, it should display phrases 5 – 1. When a user hits 11, it should display lines 11 – 1.

Hint 1: Inside the case structure, stick with the SAME order of phrases that I have above.
Hint 2: Loose the “break”.
Hint 3: case 10: System.out.println(“On the tenth day of Christmas, my true love sent to me, Ten lords a-leaping, “);"

I was never taught anything about case 10 or system.out.println. So I'm kinda lost. If anyone could just point me in the right direction I would be very grateful!

2. Originally Posted by Pfinferno
I was never taught anything about case 10 or system.out.println.
The case 10 thing is just an example, similiar to what you have seen with switch statements and case labels. The system.out.println is likely to be the result of your instructor "porting" over this question from another class he/she taught, but forgetting to change the text. Use puts or printf instead.

3. Here's a hint for you... this program is real easy and it can work because of a common error people make when writing switch()-case statements. You can actually break out of the mold and take advantage of it.

4. Ah yes this turned out to be a lot easier than I thought. Thanks for your help!