SlideShare a Scribd company logo
1 of 6
Download to read offline
main.cpp:
#include <iostream>
#include <string>
using namespace std;
class SongNode {
private:
string songTitle;
string songLength;
string songArtist;
SongNode* nextNodeRef;
public:
SongNode() {
songTitle = "";
songLength = "";
songArtist = "";
nextNodeRef = NULL;
}
SongNode(string songTitleInit, string songLengthInit, string songArtistInit);
SongNode(string songTitleInit, string songLengthInit, string songArtistInit, SongNode* nextLoc);
void InsertAfter(SongNode* nodeLoc);
SongNode* GetNext();
void PrintSongInfo();
};
SongNode::SongNode(string songTitleInit, string songLengthInit, string songArtistInit) {
this->songTitle = songTitleInit;
this->songLength = songLengthInit;
this->songArtist = songArtistInit;
this->nextNodeRef = NULL;
}
SongNode::SongNode(string songTitleInit, string songLengthInit, string songArtistInit, SongNode*
nextLoc) {
this->songTitle = songTitleInit;
this->songLength = songLengthInit;
this->songArtist = songArtistInit;
this->nextNodeRef = nextLoc;
}
void SongNode::InsertAfter(SongNode* nodeLoc) {
SongNode* tmpNext;
tmpNext = this->nextNodeRef;
this->nextNodeRef = nodeLoc;
nodeLoc->nextNodeRef = tmpNext;
}
SongNode* SongNode::GetNext() {
return this->nextNodeRef;
}
void SongNode::PrintSongInfo() {
cout << "Title: " << this->songTitle << endl;
cout << "Length: " << this->songLength << endl;
cout << "Artist: " << this->songArtist << endl << endl;
}
void PrintPlaylist(SongNode *song) {
song = song->GetNext();
while (song != NULL) {
song->PrintSongInfo();
song = song->GetNext();
}
}
int main() {
SongNode* headNode;
SongNode* currNode;
SongNode* lastNode;
string songTitle;
string songLength;
string songArtist;
headNode = new SongNode();
lastNode = headNode;
getline(cin, songTitle);
while (songTitle != "-1") {
getline(cin, songLength);
getline(cin, songArtist);
currNode = new SongNode(songTitle, songLength, songArtist);
lastNode->InsertAfter(currNode);
lastNode = currNode;
getline(cin, songTitle);
}
cout << "nLIST OF SONGS" << endl;
cout << "-------------" << endl;
PrintPlaylist(headNode);
return 0;
}
SongNode.h:
#include <iostream>
#include <string>
using namespace std;
class SongNode {
private:
string songTitle;
string songLength;
string songArtist;
SongNode* nextNodeRef; // Reference to the next node
public:
SongNode() {
songTitle = "";
songLength = "";
songArtist = "";
nextNodeRef = NULL;
}
// Constructor
SongNode(string songTitleInit, string songLengthInit, string songArtistInit);
// Constructor
SongNode(string songTitleInit, string songLengthInit, string songArtistInit, SongNode* nextLoc);
// insertAfter
void InsertAfter(SongNode* nodeLoc);
// Get location pointed by nextNodeRef
SongNode* GetNext();
// Prints song information
void PrintSongInfo();
};
// SongNode.cpp
// Constructor
SongNode::SongNode(string songTitleInit, string songLengthInit, string songArtistInit) {
this->songTitle = songTitleInit;
this->songLength = songLengthInit;
this->songArtist = songArtistInit;
this->nextNodeRef = NULL;
}
// Constructor
SongNode::SongNode(string songTitleInit, string songLengthInit, string songArtistInit, SongNode*
nextLoc) {
this->songTitle = songTitleInit;
this->songLength = songLengthInit;
this->songArtist = songArtistInit;
this->nextNodeRef = nextLoc;
}
// insertAfter
void SongNode::InsertAfter(SongNode* nodeLoc) {
SongNode* tmpNext;
tmpNext = this->nextNodeRef;
this->nextNodeRef = nodeLoc;
nodeLoc->nextNodeRef = tmpNext;
}
// Get location pointed by nextNodeRef
SongNode* SongNode::GetNext() {
return this->nextNodeRef;
}
// Prints song information
void SongNode::PrintSongInfo() {
cout << "Title: " << this->songTitle << endl;
cout << "Length: " << this->songLength << endl;
cout << "Artist: " << this->songArtist << endl << endl;
}
// main.cpp
// Write PrintPlaylist() function
void PrintPlaylist(SongNode *song) {
song = song->GetNext(); // skip the dummy head node
while (song != NULL) {
song->PrintSongInfo();
song = song->GetNext();
}
}
int main() {
SongNode* headNode;
SongNode* currNode;
SongNode* lastNode;
string songTitle;
string songLength;
string songArtist;
// Front of nodes list
headNode = new SongNode();
lastNode = headNode;
// Read user input until -1 entered
getline(cin, songTitle);
while (songTitle != "-1") {
getline(cin, songLength);
getline(cin, songArtist);
currNode = new SongNode(songTitle, songLength, songArtist);
lastNode->InsertAfter(currNode);
lastNode = currNode;
getline(cin, songTitle);
}
// Print linked list
cout << "nLIST OF SONGS" << endl;
cout << "-------------" << endl;
PrintPlaylist(headNode);
return 0;
}
SongNode.cpp:
#include "SongNode.h"
// Constructor
SongNode::SongNode(string songTitleInit, string songLengthInit, string songArtistInit) {
this->songTitle = songTitleInit;
this->songLength = songLengthInit;
this->songArtist = songArtistInit;
this->nextNodeRef = NULL;
}
// Constructor
SongNode::SongNode(string songTitleInit, string songLengthInit, string songArtistInit, SongNode*
nextLoc) {
this->songTitle = songTitleInit;
this->songLength = songLengthInit;
this->songArtist = songArtistInit;
this->nextNodeRef = nextLoc;
}
// insertAfter
void SongNode::InsertAfter(SongNode* nodeLoc) {
SongNode* tmpNext;
tmpNext = this->nextNodeRef;
this->nextNodeRef = nodeLoc;
nodeLoc->nextNodeRef = tmpNext;
}
// Get location pointed by nextNodeRef
SongNode* SongNode::GetNext() {
return this->nextNodeRef;
}
// TODO: Write PrintSongInfo() function
please solve it in c++ thank you!
Given main(0, complete the SongNode class to include the function PrintSonglnfo(). Then write
the PrintPlaylist() function in main.cpp to print all songs in the playlist. DO NOT print the dummy
head node. Ex: If the input is: Stomp! 380 The Brothers Johnson The Dude 337 Quincy Jones You
Don't own Me 151 Lesley Gore -1the output is: LIST OF SONGS Title: Stomp! Length: 380 Artist:
The Brothers Johnson Title: The Dude Length: 337 Artist: Quincy Jones Title: You Don't Own Me
Length: 151 Artist: Lesley Gore

More Related Content

Similar to maincpp include ltiostreamgt include ltstringgt.pdf

It's not working what am I doing wrong- Given main()- complete the Son.pdf
It's not working what am I doing wrong- Given main()- complete the Son.pdfIt's not working what am I doing wrong- Given main()- complete the Son.pdf
It's not working what am I doing wrong- Given main()- complete the Son.pdfaanyajoshi90
 
Can someone please help me complete the add_song function .pdf
Can someone please help me complete the add_song function .pdfCan someone please help me complete the add_song function .pdf
Can someone please help me complete the add_song function .pdfakshpatil4
 
PFB cpp code for the given problem#include iostream #include .pdf
PFB cpp code for the given problem#include iostream #include .pdfPFB cpp code for the given problem#include iostream #include .pdf
PFB cpp code for the given problem#include iostream #include .pdfmailadmin1
 
I am having the below compile errors. .pdf
I am having the below compile errors. .pdfI am having the below compile errors. .pdf
I am having the below compile errors. .pdfdbrienmhompsonkath75
 
Can someone please help me implement the addSong function .pdf
Can someone please help me implement the addSong function .pdfCan someone please help me implement the addSong function .pdf
Can someone please help me implement the addSong function .pdfakshpatil4
 
Given main(), complete the SongNode class to include the printSong.pdf
Given main(), complete the SongNode class to include the printSong.pdfGiven main(), complete the SongNode class to include the printSong.pdf
Given main(), complete the SongNode class to include the printSong.pdfillyasraja7
 
8.15 Program Playlist (C++) You will be building a linked list. Mak.pdf
8.15 Program Playlist (C++) You will be building a linked list. Mak.pdf8.15 Program Playlist (C++) You will be building a linked list. Mak.pdf
8.15 Program Playlist (C++) You will be building a linked list. Mak.pdfarenamobiles123
 
Program 02 Based on the previous problem you should impleme.pdf
Program 02 Based on the previous problem you should impleme.pdfProgram 02 Based on the previous problem you should impleme.pdf
Program 02 Based on the previous problem you should impleme.pdfaddtechglobalmarketi
 
I need help writing the methods for the song and playList class in J.pdf
I need help writing the methods for the song and playList class in J.pdfI need help writing the methods for the song and playList class in J.pdf
I need help writing the methods for the song and playList class in J.pdfarihanthtextiles
 
In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdffantoosh1
 
Help I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdfHelp I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdfmail931892
 
Problem 2 struct to hold information about a song struct So.pdf
 Problem 2 struct to hold information about a song struct So.pdf Problem 2 struct to hold information about a song struct So.pdf
Problem 2 struct to hold information about a song struct So.pdfahujaelectronics175
 
Write a program in C++ language that implements a music play.pdf
Write a program in C++ language that implements a music play.pdfWrite a program in C++ language that implements a music play.pdf
Write a program in C++ language that implements a music play.pdficonsystemsslm
 
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docx
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docxlab03build.bat@echo offclsset DRIVE_LETTER=1set.docx
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docxDIPESH30
 
Can someone solve the TODO parts of the following problem i.pdf
Can someone solve the TODO parts of the following problem i.pdfCan someone solve the TODO parts of the following problem i.pdf
Can someone solve the TODO parts of the following problem i.pdfakshpatil4
 
#include iostream #include fstream #include cstdlib #.pdf
 #include iostream #include fstream #include cstdlib #.pdf #include iostream #include fstream #include cstdlib #.pdf
#include iostream #include fstream #include cstdlib #.pdfannesmkt
 
Need help getting past an error in C++! I have all my code pasted down.docx
Need help getting past an error in C++! I have all my code pasted down.docxNeed help getting past an error in C++! I have all my code pasted down.docx
Need help getting past an error in C++! I have all my code pasted down.docxJason0x0Scottw
 
The provided codetrack_file_handling.rb class Track att.pdf
The provided codetrack_file_handling.rb class Track    att.pdfThe provided codetrack_file_handling.rb class Track    att.pdf
The provided codetrack_file_handling.rb class Track att.pdffashination
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxteyaj1
 
Please solve the TODO parts of the following probelm incl.pdf
Please solve the TODO parts of the following probelm  incl.pdfPlease solve the TODO parts of the following probelm  incl.pdf
Please solve the TODO parts of the following probelm incl.pdfaggarwalopticalsco
 

Similar to maincpp include ltiostreamgt include ltstringgt.pdf (20)

It's not working what am I doing wrong- Given main()- complete the Son.pdf
It's not working what am I doing wrong- Given main()- complete the Son.pdfIt's not working what am I doing wrong- Given main()- complete the Son.pdf
It's not working what am I doing wrong- Given main()- complete the Son.pdf
 
Can someone please help me complete the add_song function .pdf
Can someone please help me complete the add_song function .pdfCan someone please help me complete the add_song function .pdf
Can someone please help me complete the add_song function .pdf
 
PFB cpp code for the given problem#include iostream #include .pdf
PFB cpp code for the given problem#include iostream #include .pdfPFB cpp code for the given problem#include iostream #include .pdf
PFB cpp code for the given problem#include iostream #include .pdf
 
I am having the below compile errors. .pdf
I am having the below compile errors. .pdfI am having the below compile errors. .pdf
I am having the below compile errors. .pdf
 
Can someone please help me implement the addSong function .pdf
Can someone please help me implement the addSong function .pdfCan someone please help me implement the addSong function .pdf
Can someone please help me implement the addSong function .pdf
 
Given main(), complete the SongNode class to include the printSong.pdf
Given main(), complete the SongNode class to include the printSong.pdfGiven main(), complete the SongNode class to include the printSong.pdf
Given main(), complete the SongNode class to include the printSong.pdf
 
8.15 Program Playlist (C++) You will be building a linked list. Mak.pdf
8.15 Program Playlist (C++) You will be building a linked list. Mak.pdf8.15 Program Playlist (C++) You will be building a linked list. Mak.pdf
8.15 Program Playlist (C++) You will be building a linked list. Mak.pdf
 
Program 02 Based on the previous problem you should impleme.pdf
Program 02 Based on the previous problem you should impleme.pdfProgram 02 Based on the previous problem you should impleme.pdf
Program 02 Based on the previous problem you should impleme.pdf
 
I need help writing the methods for the song and playList class in J.pdf
I need help writing the methods for the song and playList class in J.pdfI need help writing the methods for the song and playList class in J.pdf
I need help writing the methods for the song and playList class in J.pdf
 
In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdf
 
Help I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdfHelp I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdf
 
Problem 2 struct to hold information about a song struct So.pdf
 Problem 2 struct to hold information about a song struct So.pdf Problem 2 struct to hold information about a song struct So.pdf
Problem 2 struct to hold information about a song struct So.pdf
 
Write a program in C++ language that implements a music play.pdf
Write a program in C++ language that implements a music play.pdfWrite a program in C++ language that implements a music play.pdf
Write a program in C++ language that implements a music play.pdf
 
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docx
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docxlab03build.bat@echo offclsset DRIVE_LETTER=1set.docx
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docx
 
Can someone solve the TODO parts of the following problem i.pdf
Can someone solve the TODO parts of the following problem i.pdfCan someone solve the TODO parts of the following problem i.pdf
Can someone solve the TODO parts of the following problem i.pdf
 
#include iostream #include fstream #include cstdlib #.pdf
 #include iostream #include fstream #include cstdlib #.pdf #include iostream #include fstream #include cstdlib #.pdf
#include iostream #include fstream #include cstdlib #.pdf
 
Need help getting past an error in C++! I have all my code pasted down.docx
Need help getting past an error in C++! I have all my code pasted down.docxNeed help getting past an error in C++! I have all my code pasted down.docx
Need help getting past an error in C++! I have all my code pasted down.docx
 
The provided codetrack_file_handling.rb class Track att.pdf
The provided codetrack_file_handling.rb class Track    att.pdfThe provided codetrack_file_handling.rb class Track    att.pdf
The provided codetrack_file_handling.rb class Track att.pdf
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docx
 
Please solve the TODO parts of the following probelm incl.pdf
Please solve the TODO parts of the following probelm  incl.pdfPlease solve the TODO parts of the following probelm  incl.pdf
Please solve the TODO parts of the following probelm incl.pdf
 

More from mukulsingh0025

Caso Plymouth Tube Company El da despus de una reunin .pdf
Caso  Plymouth Tube Company  El da despus de una reunin .pdfCaso  Plymouth Tube Company  El da despus de una reunin .pdf
Caso Plymouth Tube Company El da despus de una reunin .pdfmukulsingh0025
 
3131 Monitor control and protect communications ie i.pdf
3131 Monitor control and protect communications ie i.pdf3131 Monitor control and protect communications ie i.pdf
3131 Monitor control and protect communications ie i.pdfmukulsingh0025
 
El libro de Thomas Friedman The World Is Flat A Brief Hist.pdf
El libro de Thomas Friedman The World Is Flat A Brief Hist.pdfEl libro de Thomas Friedman The World Is Flat A Brief Hist.pdf
El libro de Thomas Friedman The World Is Flat A Brief Hist.pdfmukulsingh0025
 
25 Microfilament polarity is present due to what characteri.pdf
25 Microfilament polarity is present due to what characteri.pdf25 Microfilament polarity is present due to what characteri.pdf
25 Microfilament polarity is present due to what characteri.pdfmukulsingh0025
 
37 La fragmentacin del hbitat suele conducir a una dismin.pdf
37 La fragmentacin del hbitat suele conducir a una dismin.pdf37 La fragmentacin del hbitat suele conducir a una dismin.pdf
37 La fragmentacin del hbitat suele conducir a una dismin.pdfmukulsingh0025
 
1 Fill in the blank a The brain is to the longe b The nos.pdf
1 Fill in the blank a The brain is to the longe b The nos.pdf1 Fill in the blank a The brain is to the longe b The nos.pdf
1 Fill in the blank a The brain is to the longe b The nos.pdfmukulsingh0025
 
1 Los gerentes crean ______ a travs de la comunicacin s.pdf
1 Los gerentes crean ______ a travs de la comunicacin  s.pdf1 Los gerentes crean ______ a travs de la comunicacin  s.pdf
1 Los gerentes crean ______ a travs de la comunicacin s.pdfmukulsingh0025
 
C++ Please help me Dont use Chat GPT please Problem 1.pdf
C++ Please help me Dont use Chat GPT please  Problem 1.pdfC++ Please help me Dont use Chat GPT please  Problem 1.pdf
C++ Please help me Dont use Chat GPT please Problem 1.pdfmukulsingh0025
 
574 Chapter 28 priocioles of Eisctrocardiogriasy 6 Thind de.pdf
574 Chapter 28 priocioles of Eisctrocardiogriasy 6 Thind de.pdf574 Chapter 28 priocioles of Eisctrocardiogriasy 6 Thind de.pdf
574 Chapter 28 priocioles of Eisctrocardiogriasy 6 Thind de.pdfmukulsingh0025
 
3 Which of the following voice communications systems and s.pdf
3 Which of the following voice communications systems and s.pdf3 Which of the following voice communications systems and s.pdf
3 Which of the following voice communications systems and s.pdfmukulsingh0025
 
Vaka Analizi VERler Bir rnek Gnll ihracat kstl.pdf
Vaka Analizi   VERler Bir rnek       Gnll ihracat kstl.pdfVaka Analizi   VERler Bir rnek       Gnll ihracat kstl.pdf
Vaka Analizi VERler Bir rnek Gnll ihracat kstl.pdfmukulsingh0025
 
Problem 3 12 points FABCDBC+CD+ABCD B Give the com.pdf
Problem 3 12 points FABCDBC+CD+ABCD B Give the com.pdfProblem 3 12 points FABCDBC+CD+ABCD B Give the com.pdf
Problem 3 12 points FABCDBC+CD+ABCD B Give the com.pdfmukulsingh0025
 
The nationat debt is of growing concerm in the United states.pdf
The nationat debt is of growing concerm in the United states.pdfThe nationat debt is of growing concerm in the United states.pdf
The nationat debt is of growing concerm in the United states.pdfmukulsingh0025
 
Chetnas mind wanders when her supervisor is talking to her.pdf
Chetnas mind wanders when her supervisor is talking to her.pdfChetnas mind wanders when her supervisor is talking to her.pdf
Chetnas mind wanders when her supervisor is talking to her.pdfmukulsingh0025
 
The future value of a lump sum single value can be found u.pdf
The future value of a lump sum single value can be found u.pdfThe future value of a lump sum single value can be found u.pdf
The future value of a lump sum single value can be found u.pdfmukulsingh0025
 
The December 31 2012 trial balances of Pettie Corporation .pdf
The December 31 2012 trial balances of Pettie Corporation .pdfThe December 31 2012 trial balances of Pettie Corporation .pdf
The December 31 2012 trial balances of Pettie Corporation .pdfmukulsingh0025
 
Lea el caso Logitech a continuacin y responda las siguiente.pdf
Lea el caso Logitech a continuacin y responda las siguiente.pdfLea el caso Logitech a continuacin y responda las siguiente.pdf
Lea el caso Logitech a continuacin y responda las siguiente.pdfmukulsingh0025
 
Research paper Topic 3 Disaster Recovery Research paper.pdf
Research paper Topic 3 Disaster Recovery Research paper.pdfResearch paper Topic 3 Disaster Recovery Research paper.pdf
Research paper Topic 3 Disaster Recovery Research paper.pdfmukulsingh0025
 
Question 5 2 pts Describe the morphologic and molecular orga.pdf
Question 5 2 pts Describe the morphologic and molecular orga.pdfQuestion 5 2 pts Describe the morphologic and molecular orga.pdf
Question 5 2 pts Describe the morphologic and molecular orga.pdfmukulsingh0025
 
PRELAB Actlvity 3 Identifying Veins That Drain inte the Ve.pdf
PRELAB Actlvity 3 Identifying Veins That Drain inte the Ve.pdfPRELAB Actlvity 3 Identifying Veins That Drain inte the Ve.pdf
PRELAB Actlvity 3 Identifying Veins That Drain inte the Ve.pdfmukulsingh0025
 

More from mukulsingh0025 (20)

Caso Plymouth Tube Company El da despus de una reunin .pdf
Caso  Plymouth Tube Company  El da despus de una reunin .pdfCaso  Plymouth Tube Company  El da despus de una reunin .pdf
Caso Plymouth Tube Company El da despus de una reunin .pdf
 
3131 Monitor control and protect communications ie i.pdf
3131 Monitor control and protect communications ie i.pdf3131 Monitor control and protect communications ie i.pdf
3131 Monitor control and protect communications ie i.pdf
 
El libro de Thomas Friedman The World Is Flat A Brief Hist.pdf
El libro de Thomas Friedman The World Is Flat A Brief Hist.pdfEl libro de Thomas Friedman The World Is Flat A Brief Hist.pdf
El libro de Thomas Friedman The World Is Flat A Brief Hist.pdf
 
25 Microfilament polarity is present due to what characteri.pdf
25 Microfilament polarity is present due to what characteri.pdf25 Microfilament polarity is present due to what characteri.pdf
25 Microfilament polarity is present due to what characteri.pdf
 
37 La fragmentacin del hbitat suele conducir a una dismin.pdf
37 La fragmentacin del hbitat suele conducir a una dismin.pdf37 La fragmentacin del hbitat suele conducir a una dismin.pdf
37 La fragmentacin del hbitat suele conducir a una dismin.pdf
 
1 Fill in the blank a The brain is to the longe b The nos.pdf
1 Fill in the blank a The brain is to the longe b The nos.pdf1 Fill in the blank a The brain is to the longe b The nos.pdf
1 Fill in the blank a The brain is to the longe b The nos.pdf
 
1 Los gerentes crean ______ a travs de la comunicacin s.pdf
1 Los gerentes crean ______ a travs de la comunicacin  s.pdf1 Los gerentes crean ______ a travs de la comunicacin  s.pdf
1 Los gerentes crean ______ a travs de la comunicacin s.pdf
 
C++ Please help me Dont use Chat GPT please Problem 1.pdf
C++ Please help me Dont use Chat GPT please  Problem 1.pdfC++ Please help me Dont use Chat GPT please  Problem 1.pdf
C++ Please help me Dont use Chat GPT please Problem 1.pdf
 
574 Chapter 28 priocioles of Eisctrocardiogriasy 6 Thind de.pdf
574 Chapter 28 priocioles of Eisctrocardiogriasy 6 Thind de.pdf574 Chapter 28 priocioles of Eisctrocardiogriasy 6 Thind de.pdf
574 Chapter 28 priocioles of Eisctrocardiogriasy 6 Thind de.pdf
 
3 Which of the following voice communications systems and s.pdf
3 Which of the following voice communications systems and s.pdf3 Which of the following voice communications systems and s.pdf
3 Which of the following voice communications systems and s.pdf
 
Vaka Analizi VERler Bir rnek Gnll ihracat kstl.pdf
Vaka Analizi   VERler Bir rnek       Gnll ihracat kstl.pdfVaka Analizi   VERler Bir rnek       Gnll ihracat kstl.pdf
Vaka Analizi VERler Bir rnek Gnll ihracat kstl.pdf
 
Problem 3 12 points FABCDBC+CD+ABCD B Give the com.pdf
Problem 3 12 points FABCDBC+CD+ABCD B Give the com.pdfProblem 3 12 points FABCDBC+CD+ABCD B Give the com.pdf
Problem 3 12 points FABCDBC+CD+ABCD B Give the com.pdf
 
The nationat debt is of growing concerm in the United states.pdf
The nationat debt is of growing concerm in the United states.pdfThe nationat debt is of growing concerm in the United states.pdf
The nationat debt is of growing concerm in the United states.pdf
 
Chetnas mind wanders when her supervisor is talking to her.pdf
Chetnas mind wanders when her supervisor is talking to her.pdfChetnas mind wanders when her supervisor is talking to her.pdf
Chetnas mind wanders when her supervisor is talking to her.pdf
 
The future value of a lump sum single value can be found u.pdf
The future value of a lump sum single value can be found u.pdfThe future value of a lump sum single value can be found u.pdf
The future value of a lump sum single value can be found u.pdf
 
The December 31 2012 trial balances of Pettie Corporation .pdf
The December 31 2012 trial balances of Pettie Corporation .pdfThe December 31 2012 trial balances of Pettie Corporation .pdf
The December 31 2012 trial balances of Pettie Corporation .pdf
 
Lea el caso Logitech a continuacin y responda las siguiente.pdf
Lea el caso Logitech a continuacin y responda las siguiente.pdfLea el caso Logitech a continuacin y responda las siguiente.pdf
Lea el caso Logitech a continuacin y responda las siguiente.pdf
 
Research paper Topic 3 Disaster Recovery Research paper.pdf
Research paper Topic 3 Disaster Recovery Research paper.pdfResearch paper Topic 3 Disaster Recovery Research paper.pdf
Research paper Topic 3 Disaster Recovery Research paper.pdf
 
Question 5 2 pts Describe the morphologic and molecular orga.pdf
Question 5 2 pts Describe the morphologic and molecular orga.pdfQuestion 5 2 pts Describe the morphologic and molecular orga.pdf
Question 5 2 pts Describe the morphologic and molecular orga.pdf
 
PRELAB Actlvity 3 Identifying Veins That Drain inte the Ve.pdf
PRELAB Actlvity 3 Identifying Veins That Drain inte the Ve.pdfPRELAB Actlvity 3 Identifying Veins That Drain inte the Ve.pdf
PRELAB Actlvity 3 Identifying Veins That Drain inte the Ve.pdf
 

Recently uploaded

An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMELOISARIVERA8
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MysoreMuleSoftMeetup
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxCeline George
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptxVishal Singh
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnershipsexpandedwebsite
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................MirzaAbrarBaig5
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17Celine George
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 

Recently uploaded (20)

An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 

maincpp include ltiostreamgt include ltstringgt.pdf

  • 1. main.cpp: #include <iostream> #include <string> using namespace std; class SongNode { private: string songTitle; string songLength; string songArtist; SongNode* nextNodeRef; public: SongNode() { songTitle = ""; songLength = ""; songArtist = ""; nextNodeRef = NULL; } SongNode(string songTitleInit, string songLengthInit, string songArtistInit); SongNode(string songTitleInit, string songLengthInit, string songArtistInit, SongNode* nextLoc); void InsertAfter(SongNode* nodeLoc); SongNode* GetNext(); void PrintSongInfo(); }; SongNode::SongNode(string songTitleInit, string songLengthInit, string songArtistInit) { this->songTitle = songTitleInit; this->songLength = songLengthInit; this->songArtist = songArtistInit; this->nextNodeRef = NULL; } SongNode::SongNode(string songTitleInit, string songLengthInit, string songArtistInit, SongNode* nextLoc) { this->songTitle = songTitleInit; this->songLength = songLengthInit; this->songArtist = songArtistInit; this->nextNodeRef = nextLoc; } void SongNode::InsertAfter(SongNode* nodeLoc) { SongNode* tmpNext; tmpNext = this->nextNodeRef; this->nextNodeRef = nodeLoc; nodeLoc->nextNodeRef = tmpNext; }
  • 2. SongNode* SongNode::GetNext() { return this->nextNodeRef; } void SongNode::PrintSongInfo() { cout << "Title: " << this->songTitle << endl; cout << "Length: " << this->songLength << endl; cout << "Artist: " << this->songArtist << endl << endl; } void PrintPlaylist(SongNode *song) { song = song->GetNext(); while (song != NULL) { song->PrintSongInfo(); song = song->GetNext(); } } int main() { SongNode* headNode; SongNode* currNode; SongNode* lastNode; string songTitle; string songLength; string songArtist; headNode = new SongNode(); lastNode = headNode; getline(cin, songTitle); while (songTitle != "-1") { getline(cin, songLength); getline(cin, songArtist); currNode = new SongNode(songTitle, songLength, songArtist); lastNode->InsertAfter(currNode); lastNode = currNode; getline(cin, songTitle); } cout << "nLIST OF SONGS" << endl; cout << "-------------" << endl; PrintPlaylist(headNode); return 0; } SongNode.h: #include <iostream> #include <string> using namespace std;
  • 3. class SongNode { private: string songTitle; string songLength; string songArtist; SongNode* nextNodeRef; // Reference to the next node public: SongNode() { songTitle = ""; songLength = ""; songArtist = ""; nextNodeRef = NULL; } // Constructor SongNode(string songTitleInit, string songLengthInit, string songArtistInit); // Constructor SongNode(string songTitleInit, string songLengthInit, string songArtistInit, SongNode* nextLoc); // insertAfter void InsertAfter(SongNode* nodeLoc); // Get location pointed by nextNodeRef SongNode* GetNext(); // Prints song information void PrintSongInfo(); }; // SongNode.cpp // Constructor SongNode::SongNode(string songTitleInit, string songLengthInit, string songArtistInit) { this->songTitle = songTitleInit; this->songLength = songLengthInit; this->songArtist = songArtistInit; this->nextNodeRef = NULL; } // Constructor SongNode::SongNode(string songTitleInit, string songLengthInit, string songArtistInit, SongNode* nextLoc) { this->songTitle = songTitleInit; this->songLength = songLengthInit; this->songArtist = songArtistInit; this->nextNodeRef = nextLoc; } // insertAfter void SongNode::InsertAfter(SongNode* nodeLoc) {
  • 4. SongNode* tmpNext; tmpNext = this->nextNodeRef; this->nextNodeRef = nodeLoc; nodeLoc->nextNodeRef = tmpNext; } // Get location pointed by nextNodeRef SongNode* SongNode::GetNext() { return this->nextNodeRef; } // Prints song information void SongNode::PrintSongInfo() { cout << "Title: " << this->songTitle << endl; cout << "Length: " << this->songLength << endl; cout << "Artist: " << this->songArtist << endl << endl; } // main.cpp // Write PrintPlaylist() function void PrintPlaylist(SongNode *song) { song = song->GetNext(); // skip the dummy head node while (song != NULL) { song->PrintSongInfo(); song = song->GetNext(); } } int main() { SongNode* headNode; SongNode* currNode; SongNode* lastNode; string songTitle; string songLength; string songArtist; // Front of nodes list headNode = new SongNode(); lastNode = headNode; // Read user input until -1 entered getline(cin, songTitle); while (songTitle != "-1") { getline(cin, songLength); getline(cin, songArtist); currNode = new SongNode(songTitle, songLength, songArtist); lastNode->InsertAfter(currNode); lastNode = currNode;
  • 5. getline(cin, songTitle); } // Print linked list cout << "nLIST OF SONGS" << endl; cout << "-------------" << endl; PrintPlaylist(headNode); return 0; } SongNode.cpp: #include "SongNode.h" // Constructor SongNode::SongNode(string songTitleInit, string songLengthInit, string songArtistInit) { this->songTitle = songTitleInit; this->songLength = songLengthInit; this->songArtist = songArtistInit; this->nextNodeRef = NULL; } // Constructor SongNode::SongNode(string songTitleInit, string songLengthInit, string songArtistInit, SongNode* nextLoc) { this->songTitle = songTitleInit; this->songLength = songLengthInit; this->songArtist = songArtistInit; this->nextNodeRef = nextLoc; } // insertAfter void SongNode::InsertAfter(SongNode* nodeLoc) { SongNode* tmpNext; tmpNext = this->nextNodeRef; this->nextNodeRef = nodeLoc; nodeLoc->nextNodeRef = tmpNext; } // Get location pointed by nextNodeRef SongNode* SongNode::GetNext() { return this->nextNodeRef; } // TODO: Write PrintSongInfo() function please solve it in c++ thank you! Given main(0, complete the SongNode class to include the function PrintSonglnfo(). Then write the PrintPlaylist() function in main.cpp to print all songs in the playlist. DO NOT print the dummy head node. Ex: If the input is: Stomp! 380 The Brothers Johnson The Dude 337 Quincy Jones You
  • 6. Don't own Me 151 Lesley Gore -1the output is: LIST OF SONGS Title: Stomp! Length: 380 Artist: The Brothers Johnson Title: The Dude Length: 337 Artist: Quincy Jones Title: You Don't Own Me Length: 151 Artist: Lesley Gore