A popular pasttime among music collectors is creating "mix" tapes or cd's that contain a variety of songs taken from different albums. One frequent task is to determine if the total time of the songs selected for recording is less than the time available on the recording media (CD or audio tape). You are to write a computer program to assist with that task.
Requirementssongdata.txt
Hey_Jude 181 The_Beatles 1968
Stairway_to_Heaven 180 Led_Zeppelin 1971
Radar_Love 239 Golden_Earring 1974
Riders_On_The_Storm 543 The_Doors 1971
What's_So_Funny?_('bout_Peace,_Love,_and_Understanding) 221 Elvis_Costello 1979
No_Need_To_Argue 347 The_Cranberries 1994
Don't_Get_Fooled_Again 497 The_Who 1971
Thick_As_A_Brick 1265 Jethro_Tull 1972
Close_To_The_Edge 1130 Yes 1972
This_one_song_has_28_letters 001 Nobody 1900
Note that no blanks are allowed in the song or artist names; use
underlines to separate words. When the program begins it reads
the songlist and displays the songs
so they can be selected by the user. (If the file can't be
opened, display this error message: "Unable to open songdata.txt -
missing file?") The song length is converted
and displayed as minutes and seconds.
[ 1] 3:01 Hey_Jude
[ 2] 3:00 Stairway_to_Heaven
[ 3] 3:59 Radar_Love
[ 4] 9:03 Riders_On_The_Storm
[ 5] 3:41 What's_So_Funny?_('bout_Peac
[ 6] 5:47 No_Need_To_Argue
[ 7] 8:17 Don't_Get_Fooled_Again
[ 8] 21:05 Thick_As_A_Brick
[ 9] 18:50 Close_To_The_Edge
[10] 0:01 This_one_song_has_28_letters
Total: 0:00 Remaining: 50:00
Song number?
The user selects a song by entering the reference number displayed next to the song. Songs that have been selected by the user appear in the right hand column.
[ 1] 3:01 Hey_Jude
[ 2] 3:00 Stairway_to_Heaven
[ 3] 3:59 Radar_Love
[ 4] 9:03 Riders_On_The_Storm
[ 5] 3:41 What's_So_Funny?_('bout_Peac
[ 6] 5:47 No_Need_To_Argue
[ 7] 8:17 Don't_Get_Fooled_Again
[ 8] 21:05 Thick_As_A_Brick
[ 9] 18:50 Close_To_The_Edge
[10] 0:01 This_one_song_has_28_letters
Total: 17:20 Remaining: 32:40
Song number?
Exit the program by entering a song number of 0.
**** Not enough remaining time for song #1 ****
[ 1] 3:01 Hey_Jude
[ 2] 3:00 Stairway_to_Heaven
[ 3] 3:59 Radar_Love
[ 4] 9:03 Riders_On_The_Storm
[ 5] 3:41 What's_So_Funny?_('bout_Peac
[ 6] 5:47 No_Need_To_Argue
[ 7] 8:17 Don't_Get_Fooled_Again
[ 8] 21:05 Thick_As_A_Brick
[ 9] 18:50 Close_To_The_Edge
[10] 0:01 This_one_song_has_28_letters
Total: 48:58 Remaining: 1:02
Total: 48:58 Remaining: 1:02
Song number? 0
3 records written to playlist.txt.
543 1971 Riders_On_The_Storm The_DoorsThe number of songs written to the data file is displayed (using the format shown in the example above).
1265 1972 Thick_As_A_Brick Jethro_Tull
1130 1972 Close_To_The_Edge Yes