Question
must be in java: Problem 2: We are going to create an array of playlist that hold songs. Create a class named Song. Create 3
must be in java:
Problem 2: We are going to create an array of playlist that hold songs.
Create a class named Song.
Create 3 instance variables, title, artist and length;
Create a constructor which initializes the instance variables. It will have 3 arguments.
Create 3 methods.
Create a getTitle method which should return a title.
Create a getArtist method which should return an artist.
Create a getLength method which should return a length.
Create a call named SongTester.
Import Scanner;
Create a Scanner object.
Create an array of type Song. It should hold 5 songs and be called playlist.
In a loop:
Ask the user to enter the name of the song and assign it to name.
Ask the user to enter the artist of the song and assign it to artist.
Ask the user to enter the length of the song and assign it to length.
Create a Song object using the user input.
Add the object to playlist.
Create a variable named playListLength.
Create a second loop
Get the length of each song in the playlist array
Add the length to playListLength.
Print the length of the playlist using words to describe the output.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started