Can someone please help me get started on this code?
You are burning some music CDs for a party. You’ve arranged a list of songs in
the order in which you want to play them. However, you would like to maximize
your use of space on the CD, which holds 80 minutes of music. So, you want to
figure out the total time for a group of songs and see how well they fit.
Using functional decomposition, write program in C++ to help you do this. The
data will be read from an input file called songs.dat which you will create at
your local machine and its data is shown below.
The duration of each song read from songs.dat is recorded in seconds. Hence, if
the data read from file is 310, it means that the song’s duration is 310 seconds.
You will need to convert this to minutes and seconds, which will yield 5 minutes
and 10 seconds (See example in table below).
As you read each data from your input file, you need to keep a running total of
all the duration of all the songs read. This running total will be displayed each
time you read a new data value. Once completed reading the file, you will need to
display how much space left in the CD in terms of minutes and seconds; remember
that the total capacity is 80 minutes.
You will need to write the output both to the screen and also an output file called outsongs.dat
A sample run of the output could be like this:
Song Song Time Total Time
Number Minutes Seconds Minutes Seconds
1 5 10 5 10
2 7 42 12 52
5 4 19 17 11
3 4 33 21 44
4 9 27 31 11
6 8 55 40 6
7 5 0 45 6
There are 34 minutes and 54 seconds of space left on the 80 minute CD.
Input validation
Songs should have a minimum of 1 minute and a maximum of 10 minutes. Hence test
for any values less than 60 seconds or more than 600 seconds. You don’t need to
display any message for songs less than 1 minute or more than 10 minutes but your
code must account for it by not including them in the calculation.
Thoroughly test the program using data set shown below.
Content of the file songs.dat
310
482
601
259
983
273
567
-12
535
45
300
Start by creating an ifstream from the file. In a loop, read values from the file, perform all the operations and print the partial results on the screen and the output file. Then calculate the remaining time and print that too.