Sample Output CS 1331 Programming Exercise 04- Scanner, Static Methods, and Arrays Authors: Alyse, Sreya, Nathan, Chelsea,
Fantastic news! We've Found the answer you've been seeking!
Question:
Sample Output
Transcribed Image Text:
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: 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:
Expert Answer:
Answer rating: 100% (QA)
Below is a possible implementation of the described program java import javautilScanner public class Playlist public static void addPlaylistInfoScanne... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Are there dangers with incarcerating young people in detention facilities? What about the potential for negative long-term impact? Using three documented examples of misconduct/mistreatment of youth...
-
Oriole Company just began business and made the following four inventory purchases in June: June 1 174 units $ 1044 June 10 232 units 1624 June 15 232 units 1856 June 28 174 units 1566 $ 6090 A...
-
1. A truck is traveling horizontally to the right (Fig. 4-38).When the truck starts to slow down; the crate on the (frictionless) truck bed starts to slide. In what direction could the net force be...
-
For carbon-14 and carbon-12, how many protons and neutrons are in each nucleus? Assuming neutral atoms, how many electrons are present in an atom of carbon-14 and in an atom of carbon-12?
-
1. Working in small groups, complete the Pay Raise Worksheet. 2. After the class reconvenes, group spokespersons present group findings. Pay Raise Worksheet April Knepper is the new supervisor of an...
-
Comparative balance sheet accounts of Sharpe Company are presented below. Additional data:1. Equipment that cost $10,000 and was 60% depreciated was sold in 2012.2. Cash dividends were declared and...
-
Fort Gaines guards the western entrance to Mobile Bay. In order to prevent enemy ships from passing, it needs to be able to cover about 1 km of the bay with cannon fire. The cannons fire projectiles...
-
The information listed below refers to the employees of Lemonica Company for the year ended December 31, 2016. The wages are separated into the quarters in which they were paid to the individual...
-
2. Pizza Hut is adding pasta salad to their menu and is trying to decide what price to charge; after it makes its decision, Domino's is going to decide whether to enter the pasta salad market as...
-
Discuss a Five forces Analysis and an explanation of each for : 1. Rivalry among Existing Competitors 2. Threat of Substitute products or Services 3. Threat of New Entrants 4. Bargaining power of...
-
Discuss three types of fulfilment center mentioned below and give examples Integrated fulfilment: where internet sales are carried out alongside existing retail operations Dedicated fulfilment:...
-
Discuss emerging issues in construction contracts factoring in funding, entrepreneurship, corruption ,wars/conflict -affected countries, natural disasters amongst others, and the traditional and...
-
Discuss the concept of "job design" as it relates to criminal justice organizations. As a criminal justice administrator, how would use this tactic to improve both the job performance and motivation...
-
Discuss organizational behavior opportunities in criminal justice organizations.
-
Assuming all numbers are signed words, write a code in assembly to solve the following equation CX = (DX* AX) % ( 2 * AX * - Var1)
-
The polar coordinates of a point are given. Find the rectangular coordinates of the point. (-1, - /3)
-
Indicate, in each of the following situations, the number of exemptions the taxpayers are entitled to claim on their 2012 income tax returns. Number of Exemptions a. Donna, a 20-year-old single...
-
Jim is fired from his job as a waiter and decides to take an extended trip to Europe. After touring Europe for 3 months, Jim returns to look for a new job as a waiter. Are his job-hunting expenses...
-
Linda and Richard are married and file a joint return for 2012. During the year, Linda, who works as an accountant for a national airline, used $2,100 worth of free passes for travel on the airline;...
-
Oxford Corporation began operations in 2015 and reported pretax financial income of 225,000 for the year. Oxfords tax depreciation exceeded its book depreciation by 40,000. Oxfords tax rate for 2015...
-
At December 31, 2015, Suffolk Corporation had an estimated warranty liability of 105,000 for accounting purposes and 0 for tax purposes. (The warranty costs are not deductible until paid.) The...
-
State whether each of the following events will result in a movement along General Motors (GMs) demand curve for labor in their U.S. automobile factories or whether it will cause its demand curve for...
Study smarter with the SolutionInn App