Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are burning some music CDs for a party. Youve arranged a list of songs in the order in which you want to play them.

You are burning some music CDs for a party. Youve 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. (This should be defined as a constant). 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 or in the cloud with data shown below.

You should have a function to perform each of the following:

1.open the input file

2.print header information to both screen and an output file

3.process data from the file and print result to screen and also to an output file for each line of data read. Once end-of-file, display the information about time left on the CD to both screen and output file.

The input and output files may be closed in the main function.Here is content of the file songs.datand you MUST create your input file with this same data.

310

482

601

259

983

273

567

-12

535

45

300

Each value read is for the duration of a song in seconds. Hence first value is for 310 seconds. You will need to convert this to minutes and seconds, which will yield 5 minutes and 10 seconds.

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

Songs should have a minimum of 1 minute (60 seconds) and a maximum of 10 minutes(600 seconds).

Hence any value read from file that is less than 60 seconds or more than 600 seconds should be ignored. However, log an error message to the output file ONLY. That is, no error message to screen.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions