Question: I am java 210 student.I have the program Tunes,CD and CScollection.java. I need to add some more coding in the program..The last part is the
I am java 210 student.I have the program Tunes,CD and CScollection.java. I need to add some more coding in the program..The last part is the output of the program.
In this lab, you will be changing code in programs discussed in Chapter Seven (Section 7.3 Arrays of Objects). I have provided snippet of code in some cases to simplify, but it is essentially the same. This is the example program starting with Listing 7-7 in book. Use the 3 files attached to this lab for these changes. Run Tunes.java to view the output. (5 points)
Add two more cds of your choice to the collection. Print out again. ---
Create a int variable index in Tunes.java. This value will be used to get one title from the collection. -Add this code to CD.java (a getter): (2 points) public String getTitle() { return title; } ----------------------------------------------------------------------- Add this code to CDCollection.java: (2 points) public String findTitle (int i) { return (collection[i].getTitle()); } ---------------------------------------- Add this code to Tunes.java: (10 points)
Using a loop to allow user to enter 0 thru number of CDs Added to select and list/display a Title of CD in the list. (example below is using the number entered called index) If value entered is valid then do this line of code System.out.println(music.findTitle(index)); Index is used as the value entered, if value entered not valid try again. Allow loop to end! If the value = 1, then Come on Over will displayed. -------------------------------------------------------------------------------------------------------------------------------- (15 points) Add the code to add up the costs in the collection and display the value. Yes, there is already a totalCost but do this for 15 points. All three java classes need code added, code not completely given like above so THINK! Place this code in a for loop in CDCollection.java and add the necessary code to the other two java files shown below. This will be similar to what you did in bullet 2 above. Also look at the for loop in toString() total = total + (collection[cd].getCost()); In Tunes.java will ask for the total and print the total at end of program Total cost for collection: In CD.java will give the the cost hence [hint:] getCost() --------------------------------------------------------------------------------------------------------------------------------
Write a method to find most expensive CD. (3 pts)
Write a method to find CD with most tracks Print out results. (10 points)
My CD Collection Number of CD 4 Total Cost: $61.75 Average Cost: $15.44 CD Listing: $14.95 10 Storm Front Billy Joel $14.95 16 Come on Over Shania Twain $17.95 33 SoundTrack Les Miserables $13.90 11 GraceLand Paul Simon ------------------------------------- My CD Collection Number of CDs: 6 Total Cost: $97.69 Average Cost: $16.28 CD Listing: $14.95 10 Storm Front Billy Joel $14.95 16 Come on Over Shania Twain $17.95 33 SoundTrack Les Miserables $13.90 11 GraceLand Paul Simon $19.99 26 Double Live Garth Brooks $15.95 13 Greatest Hits Jimmy Buffet ------------------------------------- My CD Collection Number of CDs: 8 Total Cost: $134.59 Average Cost: $16.82 CD Listing: $14.95 10 Storm Front Billy Joel $14.95 16 Come on Over Shania Twain $17.95 33 SoundTrack Les Miserables $13.90 11 GraceLand Paul Simon $19.99 26 Double Live Garth Brooks $15.95 13 Greatest Hits Jimmy Buffet $16.95 10 Divide Ed Sheeran $19.95 12 Reputation Taylor Swift enter number
(-1 to quit) : 9 not valid, try again enter number (-1 to quit) : 5 Greatest Hits enter number (-1 to quit) : 3 GraceLand enter number (-1 to quit) : 2 SoundTrack enter number (-1 to quit) : 2 SoundTrack enter number (-1 to quit) : -1 Total cost for collection is: 134.59 Most expensive cd: Double CD with most tracks: SoundTrack The end folks!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
