Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question
What will be the missing line code?
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
expand button
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
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-
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education