Drop hier links of afbeeldingen om ze aan de editor toe te voegen.

An English Christmas carol.

★★★

"The Twelve Days of Christmas" is an English Christmas carol that enumerates in the manner of a cumulative song a series of increasingly numerous gifts given on each of the twelve days of Christmas.

Twelve days of Christmas

Make

Write a program that outputs the song, “The Twelve Days of Christmas”.

Success Criteria

Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.

Complete the subprogram called output_song that:

  1. Outputs the song, “The twelve days of Christmas” in the most efficient way.

    Hint

    Use an array of the days, "first", "second" etc. Use an array of the gifts. Iterate over both arrays.

Complete the main program so that:

  1. It calls the output_song procedure.

Typical inputs and outputs from the program would be:

On the first day of Christmas
My true love gave to me
A partridge in a pear tree.

On the second day of Christmas
My true love gave to me
Two turtle doves
And a partridge in a pear tree.

…
🆘 If you're really stuck, use this Parsons code sorting exercise
Complete program
// Twelve days of Christmas program

using System;

class Submission
{
---
    // -------------------------
    // Subprograms
    // -------------------------
    // Procedure to output the twelve days of Christmas
    static void output_song()
    {
---
        string[] day = {"first", "second", "third", "fourth", "fifth"};
        string[] item = {"partridge in a pear tree.", "Two turtle doves", "Three french hens", "Four calling birds", "Five gold rings"};
        int verse = 0;
        int reverse_verse = 0;
---
        // Output each verse
        for (verse = 0; verse < day.Length; verse++) 
        {
---
            if (verse > 0)
            {
---
                Console.WriteLine();
---
            }
---
            Console.WriteLine($"On the {day[verse]} day of Christmas");
            Console.WriteLine("My true love gave to me");
---
            // All the items from the previous verses are output
            for (reverse_verse = verse; reverse_verse > 0; reverse_verse--) 
            {
---
                // Output only one partridge!
                if (reverse_verse > 0)
                {
---
                    Console.WriteLine(item[reverse_verse]);
---
                }
---
            }
---
            // Needs an 'A' or 'And' prefix depending on the verse
            if (verse == 0) 
            {
---
                Console.WriteLine($"A {item[0]}");
---
            }
---
            else
            {
---
                Console.WriteLine($"And a {item[0]}");
---
            }
---
        }
---
        // End the song with a blank line
        Console.WriteLine();
---
    }


---
    // -------------------------
    // Main program
    // -------------------------
    public static void Main(string[] args)
    {
---
        output_song();
---
    }
}