Write a program to process a file containing information about your music collection.

computer science


Write a program to process a file containing information about your music collection. Each song in your song library will have a name, artist, and length (in seconds). Read this data into three arrays, two for strings (for title and artist) and one for integers (for length). Then perform the processing below.

  1. Output the song titles, artists, and times in a table.
  2. Determine and output the total length of all songs.
  3. Determine and output the longest song.
  4. Determine and output the shortest song.
  5. Output the song titles in alphabetical order, WITHOUT breaking the correspondence between titles, artists, and times.

Use at least the REQUIRED METHODS listed below, with the exact same SPELLING for method names and parameters. You are free to add any other methods.

Input Specification

The name of the input file MUST BE SPELLED EXACTLY AS Music.txt. Any deviations will result in a ZERO as none of my test cases will work. The file starts with an integer on the first line that specifies the song count. Each line afterwards represents a song. The song lines will be formatted thus:


For example, the file might contain the following data:


212:Float On:Modest Mouse

259:Cherub Rock:Smashing Pumpkins

351:The Price You Pay:Bruce Springsteen

417:Teen Age Riot:Sonic Youth

285:Portions for Foxes:Rilo Kiley

Use PRECISELY the file format described above.

The colons delimit the data on each line, which allows us to have spaces in artist and song names. You can use the colons to separate the three fields so you can place each one in the proper array (see the Hints section).

Output Specification

Output the data from the file in three columns, in the order of title, artist, and time. Left justify the title and artist in a field of 24 characters (%-24s). Right justify the time in a field of 4 characters (%4d).

Related Questions in computer science category