Write code to read a list of song durations and song names from input. For each line of input, set the duration and name of newSong. Then add newSong to songsList. Input first receives a song duration, then the name of that song (which you can assume is only one word long). Input example: 424 Time 383 Money -1 1 #include 2 #include 3 #include 4 using namespace std; 5 6 7 8 9 10 11 12 13 14 15 class Song { public: void Set DurationAndName(int songDuration, string songName) { duration songDuration; name songName; 16 17 18 19 20 21 }; 22 30 31 } void PrintSong() const cout << duration << " << name << endl; } int GetDuration () const { return duration; } string GetName() const { return name; } private: int duration; string name; 23 int main() { 24 25 26 27 28 29 vector songsList; Song newSong; int songDuration; string songName; unsigned int i; cin>> songDuration; while (songDuration >= 0) { 32 33 /* Your code goes here */ 34 newSong.Set DurationAndName (songDuration, songName);
Write code to read a list of song durations and song names from input. For each line of input, set the duration and name of newSong. Then add newSong to songsList. Input first receives a song duration, then the name of that song (which you can assume is only one word long). Input example: 424 Time 383 Money -1 1 #include 2 #include 3 #include 4 using namespace std; 5 6 7 8 9 10 11 12 13 14 15 class Song { public: void Set DurationAndName(int songDuration, string songName) { duration songDuration; name songName; 16 17 18 19 20 21 }; 22 30 31 } void PrintSong() const cout << duration << " << name << endl; } int GetDuration () const { return duration; } string GetName() const { return name; } private: int duration; string name; 23 int main() { 24 25 26 27 28 29 vector songsList; Song newSong; int songDuration; string songName; unsigned int i; cin>> songDuration; while (songDuration >= 0) { 32 33 /* Your code goes here */ 34 newSong.Set DurationAndName (songDuration, songName);
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
What will be the missing line code?

Transcribed Image Text:Write code to read a list of song durations and song names from input. For each line of input, set the duration and name of
newSong. Then add newSong to songsList. Input first receives a song duration, then the name of that song (which you can
assume is only one word long). Input example:
424 Time
383 Money
-1
1 #include <iostream>
2 #include <string>
3 #include <vector>
4 using namespace std;
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Song {
public:
void Set DurationAndName(int songDuration, string songName) {
duration songDuration;
name songName;
30
31
32
}
void PrintSong() const {
11
cout << duration <<
<<name << endl;
}
int GetDuration () const { return duration; }
string GetName() const { return name; }
private:
int duration;
string name;
21 };
22
23 int main() {
24
25
26
27
28
29
vector<Song> songsList;
Song newSong;
int songDuration;
string songName;
unsigned int i;
cin >>songDuration;
while (songDuration >= 0) {
33
/* Your code goes here */
34 newSong. Set DurationAndName (songDuration, songName);
35 playlist.push_back (newSong) ;|
2
CS Scanned with CamScanner
Check
Try again

Transcribed Image Text:Jump to level 1
Write code to read a list of song durations and song names from input. For each line of input, set the duration and name of
newSong. Then add newSong to songsList. Input first receives a song duration, then the name of that song (which you can
assume is only one word long). Input example:
424 Time
383 Money
-1
11
12
13
14
15
16
17
18
19
20
21 };
22
25
26
27
28
29
30
31
32
33
23 int main() {
24
37
38
}
void PrintSong() const {
cout << duration << " - " << name << endl;
39
40
41
42
}
int GetDuration () const { return duration; }
string GetName() const { return name; }
private:
45}
int duration;
string name;
vector<Song> songsList;
/* Your code goes here */
34 newSong. Set DurationAndName (songDuration, songName);
35 playlist.push_back (newSong) ;|
36
cin>> songDuration;
Song newSong;
int songDuration;
string songName;
unsigned int i;
cin >> songDuration;
while (songDuration >= 0) {
}
for (i = 0; i < songsList.size(); ++i) {
newSong
songsList.at(i);
newSong. PrintSong();
E'Scanned with CamScanner
return 0;
-D-D-
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education