Ask Question
25 February, 01:04

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; }

+4
Answers (1)
  1. 25 February, 02:51
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers