Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Sample Output CS 1331 Programming Exercise 04- Scanner, Static Methods, and Arrays Authors: Alyse, Sreya, Nathan, Chelsea, Jack Problem Description Every year, music streaming platforms

image text in transcribedimage text in transcribed



Sample Output 


image text in transcribed 

CS 1331 Programming Exercise 04- Scanner, Static Methods, and Arrays Authors: Alyse, Sreya, Nathan, Chelsea, Jack 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: Print to the console "Enter number of songs in playlist: 3. a. b. C. d. e. Read the user's input as an int and assign it to an int named numSongs Print to the console "Enter a playlist name: a. C 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. Print the name and number of songs in the following format: Playlist created successfully. Here are the details: Number of Songs: {numSongs} Name: {playlistName} 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: 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:

Step by Step Solution

3.48 Rating (155 Votes )

There are 3 Steps involved in it

Step: 1

Below is a possible implementation of the described program java import javautilScanner public class Playlist public static void addPlaylistInfoScanne... 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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions