Challenge 5b

Description

The purpose of this challenge is to employ the use of basic functions. This challenge will display the lyrics to the Twelve Days of Christmas.

Do Not Use

Arrays or Vectors

Requirements

  1. You may have heard the classic Christmas song that goes like this:
    On the 1st day of Christmas,
    My true love gave to me,
    A partridge in a pear tree.
    
    On the 2nd day of Christmas, 
    My true love gave to me, 
    2 turtle doves,
    And a partridge in a pear tree.
    
    On the 3rd day of Christmas,
    My true love gave to me,
    3 french hens,
    2 turtle doves,
    And a partridge in a pear tree. 
    
    On the 4th day of Christmas,
    My true love gave to me,
    4 colly birds,
    3 french hens,
    2 turtle doves,
    And a partridge in a pear tree
    
    …and so on…
    
    The complete and final verse is: 
    
    On the 12th day of Christmas,
    My true love gave to me,
    12 drummers drumming,
    11 pipers piping,
    10 lords-a-leaping,
    9 ladies dancing,
    8 maids-a-milking,
    7 swans-a-swimming,
    6 geese-a-laying,
    5 golden rings,
    4 colly birds,
    3 french hens,
    2 turtle doves,
    And a partridge in a pear tree.
    
    
  2. Write a program that will display the complete lyrics of the song.
  3. The final output will display all twelve verses. Do not prompt the user to display only one verse.
  4. Create a function that will return a number with its ordinal suffix, string get_ordinal(int). It will take a single integer parameter. It will return the number with its suffix. For example, if you call get_ordinal(5), it will return “5th” as a string. Remember that 11 and 12 are special cases that use the th suffix if you choose to use modulo division by 10. Do not use cout in this function to show the ordinal suffix. 
  5. Create a function, show_verse(int), that will display a single verse. If you pass in 3, it will display the third verse counting down from 3 french hens, down to the partridge in a pear tree. Don’t forget the beginning of the verse: “On the xx day of Christmas, my true love gave to me..”. Do not hard-code each verse in the function for display. Because this function is written specifically to show the verse, it is ok to use cout in this function. 
  6. Call the show_verse() function-from step #5 above-in a loop to display all 12 verses
  7. Remember to add a blank line after each verse
  8. Remember that the 1st verse is special in that it says “and a partridge in a pear tree”. There is no and.

Extra Challenge

At the start of the program, ask the user a choice of displaying numeric or descriptive words in the verse. Then based on the user’s choice, display the lyric.

You will have to create two new functions get_num_text(int) and get_ordinal_text(int). When this function is called as get_ordinal_text(1), it will return first instead of 1st, second instead of 2nd, and so on. get_num_text(3) will return the word three, instead of the number 3, for example.

The descriptive output of the lyric then becomes (sample excerpt below):

On the third day of Christmas, 
my true love gave to me, 
three French hens,
two turtle doves,
and a partridge in a pear tree.

LEGEND
PROGRAM OUTPUT
USER INPUT
FROM INPUT

CATALOG ID: CPP-CHAL0005b

Print Requirements