SlideShare a Scribd company logo
1 of 3
Download to read offline
Given main(), complete the SongNode class to include the printSongInfo() method. Then write
the Playlist class' printPlaylist() method 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
-1
the 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
PLAYLIST.JAVA
import java.util.Scanner;
public class Playlist {
public static void main (String[] args) {
Scanner scnr = new Scanner(System.in);
SongNode headNode;
SongNode currNode;
SongNode lastNode;
String songTitle;
int songLength;
String songArtist;
// Front of nodes list
headNode = new SongNode();
lastNode = headNode;
// Read user input until -1 entered
songTitle = scnr.nextLine();
while (!songTitle.equals("-1")) {
songLength = scnr.nextInt();
scnr.nextLine();
songArtist = scnr.nextLine();
currNode = new SongNode(songTitle, songLength, songArtist);
lastNode.insertAfter(currNode);
lastNode = currNode;
songTitle = scnr.nextLine();
}
// Print linked list
System.out.println("LIST OF SONGS");
System.out.println("-------------");
printPlaylist(headNode);
}
}
SONGNODE.JAVA
public class SongNode {
private String songTitle;
private int songLength;
private String songArtist;
private SongNode nextNodeRef; // Reference to the next node
public SongNode() {
songTitle = "";
songLength = 0;
songArtist = "";
nextNodeRef = null;
}
// Constructor
public SongNode(String songTitleInit, int songLengthInit, String songArtistInit) {
this.songTitle = songTitleInit;
this.songLength = songLengthInit;
this.songArtist = songArtistInit;
this.nextNodeRef = null;
}
// Constructor
public SongNode(String songTitleInit, int songLengthInit, String songArtistInit, SongNode
nextLoc) {
this.songTitle = songTitleInit;
this.songLength = songLengthInit;
this.songArtist = songArtistInit;
this.nextNodeRef = nextLoc;
}
// insertAfter
public void insertAfter(SongNode nodeLoc) {
SongNode tmpNext;
tmpNext = this.nextNodeRef;
this.nextNodeRef = nodeLoc;
nodeLoc.nextNodeRef = tmpNext;
}
// Get location pointed by nextNodeRef
public SongNode getNext() {
return this.nextNodeRef;
}
// TODO: Write printSongInfo() method
}

More Related Content

Similar to Given main(), complete the SongNode class to include the printSong.pdf

816 LAB Playlist output linked list Hey I have most of.pdf
816 LAB Playlist output linked list Hey I have most of.pdf816 LAB Playlist output linked list Hey I have most of.pdf
816 LAB Playlist output linked list Hey I have most of.pdfsastaindin
ย 
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
ย 
1817 LAB Playlist output linked list Given main compl.pdf
1817 LAB Playlist output linked list Given main compl.pdf1817 LAB Playlist output linked list Given main compl.pdf
1817 LAB Playlist output linked list Given main compl.pdfspshotham
ย 
maincpp include ltiostreamgt include ltstringgt.pdf
maincpp  include ltiostreamgt include ltstringgt.pdfmaincpp  include ltiostreamgt include ltstringgt.pdf
maincpp include ltiostreamgt include ltstringgt.pdfmukulsingh0025
ย 
8.8 Program Playlist (Java)You will be building a linked list. Ma.pdf
8.8 Program Playlist (Java)You will be building a linked list. Ma.pdf8.8 Program Playlist (Java)You will be building a linked list. Ma.pdf
8.8 Program Playlist (Java)You will be building a linked list. Ma.pdfARCHANASTOREKOTA
ย 
Many of us have large digital music collections that are not always .pdf
Many of us have large digital music collections that are not always .pdfMany of us have large digital music collections that are not always .pdf
Many of us have large digital music collections that are not always .pdffazanmobiles
ย 
Program 01 For this program you will complete the program in.pdf
Program 01 For this program you will complete the program in.pdfProgram 01 For this program you will complete the program in.pdf
Program 01 For this program you will complete the program in.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
ย 
Need help with this java project, as the methods are proving to be p.pdf
Need help with this java project, as the methods are proving to be p.pdfNeed help with this java project, as the methods are proving to be p.pdf
Need help with this java project, as the methods are proving to be p.pdfprajeetjain
ย 
OverviewThis project will allow you to write a program to get mo.docx
OverviewThis project will allow you to write a program to get mo.docxOverviewThis project will allow you to write a program to get mo.docx
OverviewThis project will allow you to write a program to get mo.docxjacksnathalie
ย 
You are required to implement all the classes as specified by UML di.pdf
You are required to implement all the classes as specified by UML di.pdfYou are required to implement all the classes as specified by UML di.pdf
You are required to implement all the classes as specified by UML di.pdfarorasales234
ย 
Hi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdf
Hi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdfHi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdf
Hi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdfapleathers
ย 
PLEASE I need help with my assignment I have to compelet .pdf
PLEASE I need help with my assignment I have to compelet  .pdfPLEASE I need help with my assignment I have to compelet  .pdf
PLEASE I need help with my assignment I have to compelet .pdfankit11134
ย 
Here is the code.compile g++ Playlist.cpp main.cppPlaylist.h.pdf
Here is the code.compile  g++ Playlist.cpp main.cppPlaylist.h.pdfHere is the code.compile  g++ Playlist.cpp main.cppPlaylist.h.pdf
Here is the code.compile g++ Playlist.cpp main.cppPlaylist.h.pdfANANDSALESINDIA105
ย 
In C++ please I need output please You will be building a .pdf
In C++ please I need output please   You will be building a .pdfIn C++ please I need output please   You will be building a .pdf
In C++ please I need output please You will be building a .pdfsunilverma8487
ย 
C++ Programming Search A Linked ListThe Content of songlist.txt.pdf
C++ Programming Search A Linked ListThe Content of songlist.txt.pdfC++ Programming Search A Linked ListThe Content of songlist.txt.pdf
C++ Programming Search A Linked ListThe Content of songlist.txt.pdfherminaherman
ย 

Similar to Given main(), complete the SongNode class to include the printSong.pdf (16)

816 LAB Playlist output linked list Hey I have most of.pdf
816 LAB Playlist output linked list Hey I have most of.pdf816 LAB Playlist output linked list Hey I have most of.pdf
816 LAB Playlist output linked list Hey I have most of.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
ย 
1817 LAB Playlist output linked list Given main compl.pdf
1817 LAB Playlist output linked list Given main compl.pdf1817 LAB Playlist output linked list Given main compl.pdf
1817 LAB Playlist output linked list Given main compl.pdf
ย 
maincpp include ltiostreamgt include ltstringgt.pdf
maincpp  include ltiostreamgt include ltstringgt.pdfmaincpp  include ltiostreamgt include ltstringgt.pdf
maincpp include ltiostreamgt include ltstringgt.pdf
ย 
8.8 Program Playlist (Java)You will be building a linked list. Ma.pdf
8.8 Program Playlist (Java)You will be building a linked list. Ma.pdf8.8 Program Playlist (Java)You will be building a linked list. Ma.pdf
8.8 Program Playlist (Java)You will be building a linked list. Ma.pdf
ย 
Many of us have large digital music collections that are not always .pdf
Many of us have large digital music collections that are not always .pdfMany of us have large digital music collections that are not always .pdf
Many of us have large digital music collections that are not always .pdf
ย 
Program 01 For this program you will complete the program in.pdf
Program 01 For this program you will complete the program in.pdfProgram 01 For this program you will complete the program in.pdf
Program 01 For this program you will complete the program in.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
ย 
Need help with this java project, as the methods are proving to be p.pdf
Need help with this java project, as the methods are proving to be p.pdfNeed help with this java project, as the methods are proving to be p.pdf
Need help with this java project, as the methods are proving to be p.pdf
ย 
OverviewThis project will allow you to write a program to get mo.docx
OverviewThis project will allow you to write a program to get mo.docxOverviewThis project will allow you to write a program to get mo.docx
OverviewThis project will allow you to write a program to get mo.docx
ย 
You are required to implement all the classes as specified by UML di.pdf
You are required to implement all the classes as specified by UML di.pdfYou are required to implement all the classes as specified by UML di.pdf
You are required to implement all the classes as specified by UML di.pdf
ย 
Hi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdf
Hi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdfHi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdf
Hi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdf
ย 
PLEASE I need help with my assignment I have to compelet .pdf
PLEASE I need help with my assignment I have to compelet  .pdfPLEASE I need help with my assignment I have to compelet  .pdf
PLEASE I need help with my assignment I have to compelet .pdf
ย 
Here is the code.compile g++ Playlist.cpp main.cppPlaylist.h.pdf
Here is the code.compile  g++ Playlist.cpp main.cppPlaylist.h.pdfHere is the code.compile  g++ Playlist.cpp main.cppPlaylist.h.pdf
Here is the code.compile g++ Playlist.cpp main.cppPlaylist.h.pdf
ย 
In C++ please I need output please You will be building a .pdf
In C++ please I need output please   You will be building a .pdfIn C++ please I need output please   You will be building a .pdf
In C++ please I need output please You will be building a .pdf
ย 
C++ Programming Search A Linked ListThe Content of songlist.txt.pdf
C++ Programming Search A Linked ListThe Content of songlist.txt.pdfC++ Programming Search A Linked ListThe Content of songlist.txt.pdf
C++ Programming Search A Linked ListThe Content of songlist.txt.pdf
ย 

More from illyasraja7

I really need help with this assignment it is multiple parts# Part.pdf
I really need help with this assignment it is multiple parts# Part.pdfI really need help with this assignment it is multiple parts# Part.pdf
I really need help with this assignment it is multiple parts# Part.pdfillyasraja7
ย 
I need help figuring out how to add something that make sure user en.pdf
I need help figuring out how to add something that make sure user en.pdfI need help figuring out how to add something that make sure user en.pdf
I need help figuring out how to add something that make sure user en.pdfillyasraja7
ย 
how would I write out this getRentalsByCityAndProvince function to s.pdf
how would I write out this getRentalsByCityAndProvince function to s.pdfhow would I write out this getRentalsByCityAndProvince function to s.pdf
how would I write out this getRentalsByCityAndProvince function to s.pdfillyasraja7
ย 
How much is too much transparency How much is too little Look for .pdf
How much is too much transparency How much is too little Look for .pdfHow much is too much transparency How much is too little Look for .pdf
How much is too much transparency How much is too little Look for .pdfillyasraja7
ย 
hi i need help with this Database AssignmentOverviewHere are req.pdf
hi i need help with this Database AssignmentOverviewHere are req.pdfhi i need help with this Database AssignmentOverviewHere are req.pdf
hi i need help with this Database AssignmentOverviewHere are req.pdfillyasraja7
ย 
Hamilton is a member in public practice since 2005. She is a sole pr.pdf
Hamilton is a member in public practice since 2005. She is a sole pr.pdfHamilton is a member in public practice since 2005. She is a sole pr.pdf
Hamilton is a member in public practice since 2005. She is a sole pr.pdfillyasraja7
ย 
Given the following codepackage data1;import java.util.;p.pdf
Given the following codepackage data1;import java.util.;p.pdfGiven the following codepackage data1;import java.util.;p.pdf
Given the following codepackage data1;import java.util.;p.pdfillyasraja7
ย 
Given main() in the Inventory class, define an insertAtFront() metho.pdf
Given main() in the Inventory class, define an insertAtFront() metho.pdfGiven main() in the Inventory class, define an insertAtFront() metho.pdf
Given main() in the Inventory class, define an insertAtFront() metho.pdfillyasraja7
ย 
Give a background of First National Bank (FNB) This should include.pdf
Give a background of First National Bank (FNB) This should include.pdfGive a background of First National Bank (FNB) This should include.pdf
Give a background of First National Bank (FNB) This should include.pdfillyasraja7
ย 
For your third competency project, the policy position presentation,.pdf
For your third competency project, the policy position presentation,.pdfFor your third competency project, the policy position presentation,.pdf
For your third competency project, the policy position presentation,.pdfillyasraja7
ย 
FROM The Starry Messenger ASTRONOMICAL MESSAGEWhich contains and.pdf
FROM The Starry Messenger ASTRONOMICAL MESSAGEWhich contains and.pdfFROM The Starry Messenger ASTRONOMICAL MESSAGEWhich contains and.pdf
FROM The Starry Messenger ASTRONOMICAL MESSAGEWhich contains and.pdfillyasraja7
ย 
HelloIn Operating systems, under critical sectionEach process h.pdf
HelloIn Operating systems, under critical sectionEach process h.pdfHelloIn Operating systems, under critical sectionEach process h.pdf
HelloIn Operating systems, under critical sectionEach process h.pdfillyasraja7
ย 
Find a current news article or video (within the past 12 months) tha.pdf
Find a current news article or video (within the past 12 months) tha.pdfFind a current news article or video (within the past 12 months) tha.pdf
Find a current news article or video (within the past 12 months) tha.pdfillyasraja7
ย 
Forecasters use different forecasting techniques to determine the va.pdf
Forecasters use different forecasting techniques to determine the va.pdfForecasters use different forecasting techniques to determine the va.pdf
Forecasters use different forecasting techniques to determine the va.pdfillyasraja7
ย 
Fact Scenario You act for a client in an acrimonious litigation file.pdf
Fact Scenario You act for a client in an acrimonious litigation file.pdfFact Scenario You act for a client in an acrimonious litigation file.pdf
Fact Scenario You act for a client in an acrimonious litigation file.pdfillyasraja7
ย 

More from illyasraja7 (15)

I really need help with this assignment it is multiple parts# Part.pdf
I really need help with this assignment it is multiple parts# Part.pdfI really need help with this assignment it is multiple parts# Part.pdf
I really need help with this assignment it is multiple parts# Part.pdf
ย 
I need help figuring out how to add something that make sure user en.pdf
I need help figuring out how to add something that make sure user en.pdfI need help figuring out how to add something that make sure user en.pdf
I need help figuring out how to add something that make sure user en.pdf
ย 
how would I write out this getRentalsByCityAndProvince function to s.pdf
how would I write out this getRentalsByCityAndProvince function to s.pdfhow would I write out this getRentalsByCityAndProvince function to s.pdf
how would I write out this getRentalsByCityAndProvince function to s.pdf
ย 
How much is too much transparency How much is too little Look for .pdf
How much is too much transparency How much is too little Look for .pdfHow much is too much transparency How much is too little Look for .pdf
How much is too much transparency How much is too little Look for .pdf
ย 
hi i need help with this Database AssignmentOverviewHere are req.pdf
hi i need help with this Database AssignmentOverviewHere are req.pdfhi i need help with this Database AssignmentOverviewHere are req.pdf
hi i need help with this Database AssignmentOverviewHere are req.pdf
ย 
Hamilton is a member in public practice since 2005. She is a sole pr.pdf
Hamilton is a member in public practice since 2005. She is a sole pr.pdfHamilton is a member in public practice since 2005. She is a sole pr.pdf
Hamilton is a member in public practice since 2005. She is a sole pr.pdf
ย 
Given the following codepackage data1;import java.util.;p.pdf
Given the following codepackage data1;import java.util.;p.pdfGiven the following codepackage data1;import java.util.;p.pdf
Given the following codepackage data1;import java.util.;p.pdf
ย 
Given main() in the Inventory class, define an insertAtFront() metho.pdf
Given main() in the Inventory class, define an insertAtFront() metho.pdfGiven main() in the Inventory class, define an insertAtFront() metho.pdf
Given main() in the Inventory class, define an insertAtFront() metho.pdf
ย 
Give a background of First National Bank (FNB) This should include.pdf
Give a background of First National Bank (FNB) This should include.pdfGive a background of First National Bank (FNB) This should include.pdf
Give a background of First National Bank (FNB) This should include.pdf
ย 
For your third competency project, the policy position presentation,.pdf
For your third competency project, the policy position presentation,.pdfFor your third competency project, the policy position presentation,.pdf
For your third competency project, the policy position presentation,.pdf
ย 
FROM The Starry Messenger ASTRONOMICAL MESSAGEWhich contains and.pdf
FROM The Starry Messenger ASTRONOMICAL MESSAGEWhich contains and.pdfFROM The Starry Messenger ASTRONOMICAL MESSAGEWhich contains and.pdf
FROM The Starry Messenger ASTRONOMICAL MESSAGEWhich contains and.pdf
ย 
HelloIn Operating systems, under critical sectionEach process h.pdf
HelloIn Operating systems, under critical sectionEach process h.pdfHelloIn Operating systems, under critical sectionEach process h.pdf
HelloIn Operating systems, under critical sectionEach process h.pdf
ย 
Find a current news article or video (within the past 12 months) tha.pdf
Find a current news article or video (within the past 12 months) tha.pdfFind a current news article or video (within the past 12 months) tha.pdf
Find a current news article or video (within the past 12 months) tha.pdf
ย 
Forecasters use different forecasting techniques to determine the va.pdf
Forecasters use different forecasting techniques to determine the va.pdfForecasters use different forecasting techniques to determine the va.pdf
Forecasters use different forecasting techniques to determine the va.pdf
ย 
Fact Scenario You act for a client in an acrimonious litigation file.pdf
Fact Scenario You act for a client in an acrimonious litigation file.pdfFact Scenario You act for a client in an acrimonious litigation file.pdf
Fact Scenario You act for a client in an acrimonious litigation file.pdf
ย 

Recently uploaded

SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
ย 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
ย 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111GangaMaiya1
ย 
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfDiuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfKartik Tiwari
ย 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
ย 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
ย 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
ย 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....Ritu480198
ย 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
ย 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17Celine George
ย 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
ย 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17Celine George
ย 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
ย 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
ย 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
ย 
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptx
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptxMichaelis Menten Equation and Estimation Of Vmax and Tmax.pptx
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptxRugvedSathawane
ย 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsNbelano25
ย 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
ย 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
ย 
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
ย 

Recently uploaded (20)

SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
ย 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
ย 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
ย 
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfDiuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
ย 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
ย 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
ย 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
ย 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
ย 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
ย 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
ย 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
ย 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
ย 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
ย 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
ย 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
ย 
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptx
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptxMichaelis Menten Equation and Estimation Of Vmax and Tmax.pptx
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptx
ย 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
ย 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
ย 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
ย 
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...
ย 

Given main(), complete the SongNode class to include the printSong.pdf

  • 1. Given main(), complete the SongNode class to include the printSongInfo() method. Then write the Playlist class' printPlaylist() method 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 -1 the 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 PLAYLIST.JAVA import java.util.Scanner; public class Playlist { public static void main (String[] args) { Scanner scnr = new Scanner(System.in);
  • 2. SongNode headNode; SongNode currNode; SongNode lastNode; String songTitle; int songLength; String songArtist; // Front of nodes list headNode = new SongNode(); lastNode = headNode; // Read user input until -1 entered songTitle = scnr.nextLine(); while (!songTitle.equals("-1")) { songLength = scnr.nextInt(); scnr.nextLine(); songArtist = scnr.nextLine(); currNode = new SongNode(songTitle, songLength, songArtist); lastNode.insertAfter(currNode); lastNode = currNode; songTitle = scnr.nextLine(); } // Print linked list System.out.println("LIST OF SONGS"); System.out.println("-------------"); printPlaylist(headNode); } } SONGNODE.JAVA public class SongNode { private String songTitle; private int songLength; private String songArtist; private SongNode nextNodeRef; // Reference to the next node
  • 3. public SongNode() { songTitle = ""; songLength = 0; songArtist = ""; nextNodeRef = null; } // Constructor public SongNode(String songTitleInit, int songLengthInit, String songArtistInit) { this.songTitle = songTitleInit; this.songLength = songLengthInit; this.songArtist = songArtistInit; this.nextNodeRef = null; } // Constructor public SongNode(String songTitleInit, int songLengthInit, String songArtistInit, SongNode nextLoc) { this.songTitle = songTitleInit; this.songLength = songLengthInit; this.songArtist = songArtistInit; this.nextNodeRef = nextLoc; } // insertAfter public void insertAfter(SongNode nodeLoc) { SongNode tmpNext; tmpNext = this.nextNodeRef; this.nextNodeRef = nodeLoc; nodeLoc.nextNodeRef = tmpNext; } // Get location pointed by nextNodeRef public SongNode getNext() { return this.nextNodeRef; } // TODO: Write printSongInfo() method }