//Defines the user input necessary to run the program. Action is in the do-while loop.
String keepWriting = "y";

//Do while loop
do
{
//Asks for the name of the composition and goes to next line.
System.out.print ("Enter the name of the song or composition: ");
songTitle = scan.nextLine();

//Asks for the date at which the composition was created and goes to next line.
System.out.print ("Enter the date: ");
songDate = scan.nextLine();

//Asks for the number of instrumentla or miscellaneous parts in the song.
System.out.print ("Enter the number of parts in the song: ");
songParts = scan.nextInt();
scan.nextLine();

// Creates a new song and adds it to the tracklist
Portfolio portfolio = new Portfolio(songTitle, songDate, songParts);
tracks.add (portfolio);

// Prints the contents of the tracks object using println
total += (portfolio.getParts());
ListIterator iterator = tracks.listIterator();
while (iterator.hasNext())

System.out.println(iterator.next());

//Asks if the user wishes to continue programming.
System.out.print ("Continue composing (y/n)? ");
keepWriting = scan.nextLine();
}
//End of the do while loop. Continues the programming if "y" was inputed. Otherwise, prints out
//the current contents of the array.

do you mind explaining your code though? i'm not super adept at coding, if you hadn't noticed.

also, how/where exactly do i implement your code in my program?

thanks again

If you're really lazy you can put that method in your Track class and call it whenever you need a number (in a certain range) see its parameter list for details. It returns an int in the range [lo, hi]. Your Track class is going to look like this: