SlideShare a Scribd company logo
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.pdf
aanyajoshi90
 
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
akshpatil4
 
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
mailadmin1
 
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
dbrienmhompsonkath75
 
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
akshpatil4
 
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
illyasraja7
 
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
arenamobiles123
 
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
addtechglobalmarketi
 
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
arihanthtextiles
 
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
fantoosh1
 
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
mail931892
 
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
ahujaelectronics175
 
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
iconsystemsslm
 
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
DIPESH30
 
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
akshpatil4
 
#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
annesmkt
 
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
Jason0x0Scottw
 
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
fashination
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docx
teyaj1
 
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
aggarwalopticalsco
 

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 .pdf
mukulsingh0025
 
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
mukulsingh0025
 
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
mukulsingh0025
 
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
mukulsingh0025
 
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
mukulsingh0025
 
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
mukulsingh0025
 
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
mukulsingh0025
 
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
mukulsingh0025
 
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
mukulsingh0025
 
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
mukulsingh0025
 
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
mukulsingh0025
 
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
mukulsingh0025
 
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
mukulsingh0025
 
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
mukulsingh0025
 
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
mukulsingh0025
 
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
mukulsingh0025
 
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
mukulsingh0025
 
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
mukulsingh0025
 
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
mukulsingh0025
 
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
mukulsingh0025
 

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

Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 

Recently uploaded (20)

Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 

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