Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Scanner; import java.util.ArrayList; import java.util.Collections; public class Playlist { public static void printMenu ( String playlistTitle ) { System.out.println ( playlistTitle + PLAYLIST MENU

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
public class Playlist {
public static void printMenu(String playlistTitle){
System.out.println(playlistTitle + "PLAYLIST MENU");
System.out.println("a - Add song");
System.out.println("d - Remove Song");
System.out.println("c - Change position of song");
System.out.println("s - Output songs by specific artist");
System.out.println("t - Output total time of playlist");
System.out.println("o - Output full playlist");
System.out.println("q - Quit");
}
public static SongEntry executeMenu(char option, String playlistTitle, SongEntry headNode, Scanner scnr){
SongEntry tailNode = headNode;
if(tailNode!=null){
while(tailNode.getNext()!=null){
tailNode = tailNode.getNext();
}
}
if(option =='a'){
// Perform "Add song"
scnr.nextLine();
System.out.println("ADD SONG");
System.out.println("Enter song's unique ID:");
String uniqueID = scnr.nextLine();
System.out.println("Enter song's name:");
String songName = scnr.nextLine();
System.out.println("Enter artist's name:");
String artistName = scnr.nextLine();
System.out.println("Enter song's length (in seconds):");
int songLength = scnr.nextLine();
SongEntry newSong = new SongEntry(uniqueID, songName, artistName, songLength);
if(headNode == null){
headNode = newSong;
}
else {
tailNode.insertAfter(newSong);
tailNode = tailNode.getNext();
}
}
else if(option =='d'){
// Perform "Remove song"
}
else if(option =='c'){
// Perform " Change position of song"
}
else if(option =='s'){
// Output songs by specific artist
} else if(option =='t'){
// "Output total time of playlist"
}
else if(option =='o'){
//"o - Output full playlist"
System.out.println(playlistTitle +"- OUTPUT FULL PLAYLIST");
if(headNode ==null){
System.out.println("Playlist is empty");
System.out.println("");
}
else {
int numNodes =1;
SongEntry currPrintNode = headNode;
while(currPrintNode!=null){
System.out.println(numNode +".");
currPrintNode.printPlaylistSongs();
currPrintNode = currPrintNode.getNext();
numNodes++;
System.out.println("");
}
}
return headNode;
}
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
System.out.println("Enter playlist's title:");
String playlistTitle = scnr.nextLine();
System.out.println("");
printMenu(playlistTitle);
System.out.println("Choose an option:");
char menuOption = scnr.nextLine().charAt(0);
SongEntry headNode = null;
while(menuOption!='q'){
if(menuOption =='a'||'d'||'c'||'s'||'t'||'o'){
headNode = executeMenu(menuOption, playlistTitle, headNode, scnr);
}
else {
System.out.println("Wrong menu selection");
}
System.out.println("Choose an option:");
menuOption = scnr.nextLine().charAt(0);
}
}
}
I'M GETTING AN ERROR THAT STATES "public static void main(String[] args){" IS AN ILLEGAL START OF EXPRESSION. I WOULD LOVE IF SOMEONE COULD HELP ME FIX THAT. THANK YOU

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

Step: 3

blur-text-image

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

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions

Question

To find integral of sin(logx) .

Answered: 1 week ago