Question
Write a Java program that: Reads a file containing a list of Rolling Stone magazine's top songs of all time. Prints them out as a
Write a Java program that: Reads a file containing a list of Rolling Stone magazine's top songs of all time. Prints them out as a countdown list (descending order). Create a package called "rockcountdown" You will be implementing the code for the following class diagram: Create the Song class: Use the New Class wizard to create a new class. Add the rank, title, and artist fields to the Song. Add getters and setters Add a constructor Verify that Song objects can be created an initialized: Create a new package under the src folder called unittest. Download (right-click Save Link As...) SongListTester.java Download SongListTester.java into unittest. Right-click on your project, then choose Refresh to show the new file as in your project. Run | Run As | JUnit Test. If you've coded Song up correctly, the testNewSongFromFields() test will pass, and the JUnit view in Eclipse will show a green bar. The console will show your score. If there are any problems, fix them so that testNewSongFromFields passes. Allow a new Song object to be created from a tab delimited string. In the next step, we'll build the Main class shown in the UML diagram above. It will have a method called main(), that is the starting point for our application. main()'s basic job is shown in the diagram below. Details are given in the steps after the diagram. Main class: Add code to main() to do the following: Scan the song list filename from the standard input (don't print a prompt to the user). You can use readLine() Download readLine() to get the filename from the user. An alternative is to use the Scanner (Links to an external site.) object's (Links to an external site.) nextLine() method. Read all lines of the file into a String with readFile() method. Create a new ArrayList. For each line in the list of lines from the file: Create a new song object from the line. Add the song object to the ArrayList. Next, create a StringBuilder (Links to an external site.) that will hold the text we want to output. Iterate through the array list from the last song to the first. At each song, append: the song's rank, "\t", the song's title, and " " to the StringBuilder. Write the StringBuilder to the standard output (use println(), not System.out.println()). This will result in a blank line after the last song is printed. Write "Complete" to the standard 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