Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4 . 1 3 LAB: Playlist ( output linked list ) Given main ( ) , complete the songNode class to include the printSongInfo (

4.13 LAB: Playlist (output linked list)
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:
import java.util.Scanner;
public class Playlist {
// TODO: Write method to ouptut list of songs
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);
}
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions