Question: We have program called Tunes,Cd,CDCollection in java Foundations chapter 7 arrays (page 356,listing 7.7,358,Listing 7.8,359,Listing 7.9) With the help of these programs, we have to
We have program called Tunes,Cd,CDCollection in java Foundations chapter 7 arrays (page 356,listing 7.7,358,Listing 7.8,359,Listing 7.9) With the help of these programs, we have to added more coding into it. Below are the list of codings that we have to added.
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):
public String getTitle()
{
return title;
}
------------------------------------------------------------------------------
Add this code to CDCollection.java:
public String findTitle (int i)
{
return (collection[i].getTitle());
}
-----------------------------------------------------------------------------
Add this code to Tunes.java:
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.
--------------------------------------------------------------------------------------------------------------------------------
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.
Write a method to find CD with most tracks
Print out results.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
