Ask Question
7 November, 02:49

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

+3
Answers (1)
  1. 7 November, 03:08
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers