Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 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. Dont 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 users 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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

Students also viewed these Databases questions

Question

2. Are you varying your pitch (to avoid being monotonous)?

Answered: 1 week ago

Question

3. Are you varying your speaking rate and volume?

Answered: 1 week ago