Ask Question
2 October, 06:17

Write Album's PrintSongsShorterThan () to print all the songs from the album shorter than the value of the parameter songDuration. Use Song's PrintSong () to print the songs.

#include #include #include using namespace std; class Song { public: void SetNameAndDuration (string songName, int songDuration) { name = songName; duration = songDuration; } void PrintSong () const { cout << name << " - " << duration <> currentName; while (currentName! = "quit") { / * Your code goes here * / } for (i = 0; i < playlist. size (); + +i) { currentSong = playlist. at (i); currentSong. PrintSong (); } return 0; }

+2
Answers (1)
  1. 2 October, 08:03
    0
    kindly check explainations for code

    Explanation:

    Check below for program code.

    #include

    #include

    #include

    using namespace std;

    class Song

    {

    public:

    void SetNameAndDuration (string songName, int songDuration)

    {

    name = songName;

    duration = songDuration;

    }

    void PrintSong () const

    {

    cout << name << " - " << duration << endl;

    }

    string GetName () const { return name; }

    int GetDuration () const { return duration; }

    private:

    string name;

    int duration;

    };

    class Album

    {

    public:

    void SetName (string albumName) { name = albumName; }

    void InputSongs ();

    void PrintName () const { cout << name << endl; }

    void PrintSongsShorterThan (int songDuration) const;

    private:

    string name;

    vector albumSongs;

    };

    void Album::InputSongs ()

    {

    Song currSong;

    string currName;

    int currDuration;

    cin >> currName;

    while (currName! = "quit")

    {

    cin >> currDuration;

    currSong. SetNameAndDuration (currName, currDuration);

    albumSongs. push_back (currSong);

    cin >> currName;

    }

    }

    void Album::PrintSongsShorterThan (int songDuration) const

    {

    unsigned int i;

    Song currSong;

    cout << "Songs shorter than " << songDuration << " seconds:" << endl;

    / * Your code goes here * /

    for (int i=0; i
    currSong = albumSongs. at (i);

    if (currSong. GetDuration ()
    currSong. PrintSong ();

    }

    }

    }

    int main ()

    {

    Album musicAlbum;

    string albumName;

    getline (cin, albumName);

    musicAlbum. SetName (albumName);

    musicAlbum. InputSongs ();

    musicAlbum. PrintName ();

    musicAlbum. PrintSongsShorterThan (210);

    return 0;

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write Album's PrintSongsShorterThan () to print all the songs from the album shorter than the value of the parameter songDuration. Use ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers