Rap 1 Рop 2 Classical 0 Hip Hop 2 Rock 2 Lo Fi 0 c. The returned array should contain the follow Croato a puhlic ctatic mothod namnd nlaul mothod nam ed

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Java Code

Problem Description

Every year, music streaming platforms release a summary of a user’s listening statistics throughout the

year. As a result, many other websites have emerged evaluating different aspects of listening habits.

Your job is to create a program that creates and evaluates the genres of the songs within the playlist and

decide how often they will be listened to based on their popularity. This assignment will test your basic

knowledge of Scanner, static methods, and arrays.

Notes:

• You must reuse code when possible. Look for hints suggesting code reuse.

• Only create ONE Scanner object (when prompted in the main method) and reuse it whenever you need to

read more input. Creation/use of more than one Scanner may result in a zero for the assignment!

Solution Description

1. Create a class named Playlist

2. Create a public static method named addPlaylistInfo that takes in a Scanner object and does not

return anything. Prompts should be on the same line as user input. Each unique prompt should be printed

on separate lines. Within this method:

a. Print to the console “Enter number of songs in playlist: ”

b. Read the user’s input as an int and assign it to an int named numSongs

c. Print to the console “Enter a playlist name: ”

d. Read the user’s input as a String and assign it to a String named playlistName. The

playlist name may contain spaces, so the entire line of user input should be read in.

e. Print the name and number of songs in the following format:

Playlist created successfully. Here are the details:

Number of Songs: {numSongs}

Name: {playlistName}

3. Create a public static method named genreTally that takes in the following two parameters: a

String[] named genreArray, which represents the actual genres found within a playlist, and

another String[] named genres, which represents all possible genres that can be found within a

playlist. This method should return an int[] that represents the tally of each genre present within the

playlist. Within this method:

a. Print the following statement once: “The following types of genres are in

your playlist:”

b. For each String in genres, loop through the genreArray and keep a tally of how many

songs of each genre exists within genreArray. Then, print out a new line with the genre and

the total number of that type of genre.

i. HINT: Make sure that this method works for any size genreArray it receives

ii. For example, if genreArray contains [“Rap”, “Rock”, “Rock”, “Pop”,

“Pop”, “Hip Hop”, “Hip Hop”] and genres contains [“Rap”, “Pop”,

“Classical”, “Hip Hop”, “Rock”, “Lo Fi”] you should print out:

Rap 1

Pop 2

Classical 0

Hip Hop 2

Rock 2

Lo Fi 0

c. The returned array should contain the following values: [1, 2, 0, 2, 3, 0]

4. Create a public, static method named playlistScores that takes in three String[] parameters

named playlist1, playlist2, and genres in that order. This method should return nothing.

Within this method:

a. Calculate the popularity of each playlist array. To calculate the popularity of a playlist array, take

the sum of each element within the array multiplied by its index.

i. HINT: You already have a method that calculates the amount of each genre found within

a playlist. You must use that method when calculating playlist popularity.

ii. For example, the “score” of this playlist: [“Rap”, “Rap”, “Rap”, “Rap”,

“Rap”, “Pop”] using the genres array of

[“Rap”, “Pop”, “Classical”, “Hip Hop”, “Rock”, “Lo Fi”]

would be 1 because there are 5 “Rap” songs

The rest is in the image.

 

 

 

Rap 1
Pop 2
Classical 0
Нip Hop 2
Rock 2
Lo Fi 0
The returned array should contain the following values: [1, 2, 0, 2, 3, 0]
c.
4.
Create a public, static method named playlistScores that takes in three String[] parameters
named playlist1,playlist2, and genres in that order. This method should return nothing.
Within this method:
a.
Calculate the popularity of each playlist array. To calculate the popularity of a playlist array, take
the sum of each element within the array multiplied by its index.
i. HINT: You already have a method that calculates the amount of each genre found within
a playlist. You must use that method when calculating playlist popularity.
ii. For example, the "score" of this playlist: ["Rap", "Rap", "Rap", "Rap",
"Rap", "Pop"] using the genres array of
["Rap", "Pop", "Classical", "Hip Hop", "Rock", "Lo Fi"]
would be 1 because there are 5 "Rap" songs which are located at index 0 in genres
and there is 1 "Pop" song which is located at index 1 in genres. 5*0+ 1*1 = 1.
b. If playlistl's score is greater than playlist2's score, print "The first playlist
is likely to have more listeners than the second."
c. If playlist2's score is greater than playlistl's score, print "The second playlist
is likely to have more listeners than the first."
d.
If the two scores are equal, print "The two playlists are predicted to perform
equally well."
5.
Create a main method.
Create a String [] named genres with the following values: "Rap", "Pop",
"Classical", "Hip Hop", "Rock", and "Lo Fi".
Declare two String[] variables named playlistl and playlist2, respectively.
а.
b.
i.
These arrays should have a length of 7 and be filled with random values from the
genres array you already declared.
Note: you don't have to use Math.random ( ), you can pick whatever values you want.
i.
с.
Create a Scanner object named scan.
REMINDER: This is the ONLY instance of Scanner you should create!
d.
Print the numbers of songs on each playlist and give it a name. This information should be input
from the user.
HINT: you have already created the method that does this.
Print out the "Tally" of genres found within each playlist.
е.
HINT: you have already created the method that does this.
f. Compare the popularity of the playlists to see which one is likely to have more listeners.
HINT: you have already created the method that does this.
Transcribed Image Text:Rap 1 Pop 2 Classical 0 Нip Hop 2 Rock 2 Lo Fi 0 The returned array should contain the following values: [1, 2, 0, 2, 3, 0] c. 4. Create a public, static method named playlistScores that takes in three String[] parameters named playlist1,playlist2, and genres in that order. This method should return nothing. Within this method: a. Calculate the popularity of each playlist array. To calculate the popularity of a playlist array, take the sum of each element within the array multiplied by its index. i. HINT: You already have a method that calculates the amount of each genre found within a playlist. You must use that method when calculating playlist popularity. ii. For example, the "score" of this playlist: ["Rap", "Rap", "Rap", "Rap", "Rap", "Pop"] using the genres array of ["Rap", "Pop", "Classical", "Hip Hop", "Rock", "Lo Fi"] would be 1 because there are 5 "Rap" songs which are located at index 0 in genres and there is 1 "Pop" song which is located at index 1 in genres. 5*0+ 1*1 = 1. b. If playlistl's score is greater than playlist2's score, print "The first playlist is likely to have more listeners than the second." c. If playlist2's score is greater than playlistl's score, print "The second playlist is likely to have more listeners than the first." d. If the two scores are equal, print "The two playlists are predicted to perform equally well." 5. Create a main method. Create a String [] named genres with the following values: "Rap", "Pop", "Classical", "Hip Hop", "Rock", and "Lo Fi". Declare two String[] variables named playlistl and playlist2, respectively. а. b. i. These arrays should have a length of 7 and be filled with random values from the genres array you already declared. Note: you don't have to use Math.random ( ), you can pick whatever values you want. i. с. Create a Scanner object named scan. REMINDER: This is the ONLY instance of Scanner you should create! d. Print the numbers of songs on each playlist and give it a name. This information should be input from the user. HINT: you have already created the method that does this. Print out the "Tally" of genres found within each playlist. е. HINT: you have already created the method that does this. f. Compare the popularity of the playlists to see which one is likely to have more listeners. HINT: you have already created the method that does this.
Sample Output:
Enter number of songs in playlist: 7
Enter a playlist name: Playlist 1
Playlist created successfully. Here are the details:
Number of Songs: 7
Name: Playlist 1
Enter number of songs in playlist: 7
Enter a playlist name: Playlist 2
Playlist created successfully. Here are the details:
Number of Songs: 7
Name: Playlist 2
The following types of genres are in your playlist:
Rap 0
Pop 3
Classical 0
Hip Hop 2
Rock 1
Lo Fi 1
The following types of genres are in your playlist:
Rap 0
Pop 2
Classical 1
Нip Hop 0
Rock 1
Lo Fi 3
The second playlist is likely to be more popular than the first.
Transcribed Image Text:Sample Output: Enter number of songs in playlist: 7 Enter a playlist name: Playlist 1 Playlist created successfully. Here are the details: Number of Songs: 7 Name: Playlist 1 Enter number of songs in playlist: 7 Enter a playlist name: Playlist 2 Playlist created successfully. Here are the details: Number of Songs: 7 Name: Playlist 2 The following types of genres are in your playlist: Rap 0 Pop 3 Classical 0 Hip Hop 2 Rock 1 Lo Fi 1 The following types of genres are in your playlist: Rap 0 Pop 2 Classical 1 Нip Hop 0 Rock 1 Lo Fi 3 The second playlist is likely to be more popular than the first.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY