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. Write and design a C++ program to help you do this. The data are on the file songs.dat. The time is entered as seconds. For example, if a song takes 7 minutes and 42 seconds to play, the data entered in the data file for that songs would be 462.

After all the data has been read, the application should print a message indicating the time remaining on the CD.

The output should be in the form of a table with columns and headings written on a file. For example:

Song Song Time Total Time
Number Minutes Seconds Minutes Seconds
------- ------- ------- ------- -------
1 5 10 5 10
2 7 42 12 52
3 4 19 17 11
4 4 33 21 44
5 10 27 32 11
6 8 55 41 6
7 5 0 46 6

There are 33 minutes and 54 seconds of space left on the 80 minute CD.

Note that the output converts the input from seconds to minutes and seconds. Use meaningful variable names, proper indentation, and appropriate comments. Thoroughly test the program using your own data sets.

Recommended Answers

All 19 Replies

You have described your problem well enough for us to help, but we won't, because you need to show us effort, as that will show us that you are committed to the task and want to learn, and you don't just want to cream code off of us.

Lol?
First write all your code

for (int i = 0; i< a_lot; i++ ) 
{check for errors, compile it
}

debug it untill it works!

Then post the code here, if there are some strange errors that you dont understand. Maybe we can?

Good luck mate, I'll mark this ' -1 '...

Well thank you if i know were to start then i wouldnt ask !!!!! LOL

Go to www.xoax.net for a great basic Win32 C++ tutorial using windows Visual c++.
Should help you all the way to your program, if you know c++.

If you don't know any c++, google for a tutorial, you have a long way to go.

You could also ask an experienced developer, who could make the program for you. It will cost you $$$ though.

Good luck.

Go to www.xoax.net for a great basic Win32 C++ tutorial using windows Visual c++.
Should help you all the way to your program, if you know c++.

If you don't know any c++, google for a tutorial, you have a long way to go.

You could also ask an experienced developer, who could make the program for you. It will cost you $$$ though.

Good luck.

thanks

You have described your problem well enough for us to help, but we won't, because you need to show us effort, as that will show us that you are committed to the task and want to learn, and you don't just want to cream code off of us.

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])

{
int songNumber = 1 2 3 4 5 6 7;
int songMinutes = 5 7 4 4 10 8 5;
int songSeconds = 10 42 19 33 27 55 0;
int timeSeconds = 10 52 11 44 11 6 6 ;
int totalMinutes = 5 12 17 21 32 41 46;

}
totalMinutes = (usedMinutes+currentMinutes);
totalSeconds = (usedSeconds + currentSeconds);

int songNumber = 1 2 3 4 5 6 7;

This is illegal. Try this:

int songNumber[] = {1, 2, 3, 4, 5, 6, 7};

Code tags please nikki33.
You will need to repeat what VernonDozier has said for lines 9 to 13 (I think, this is why you put code tags ;) ). Also, you don't need the brackets when doing addition on the bottom line. You can delete the args for your main function, so it's just:

int main()
{

}
int songNumber = 1 2 3 4 5 6 7;

This is illegal. Try this:

int songNumber[] = {1, 2, 3, 4, 5, 6, 7};

ok should it be

#include <cstdlib>
#include <iostream>

using namespace std;

int main ()

{

}

int songNumber[] = {1 2 3 4 5 6 7};
int songMinutes[] = {5 7 4 4 10 8 5};
int songSeconds [] = {10 42 19 33 27 55 0};
int timeSeconds[] = {10 52 11 44 11 6 6 };
int totalMinutes[] = {5 12 17 21 32 41 46};

{
totalMinutes = (usedMinutes+currentMinutes);
totalSeconds = (usedSeconds + currentSeconds);
}

Code tags. Please use them.

[code]

// place code here

[/code]


ok should it be

#include <cstdlib>
#include <iostream>

using namespace std;

int main ()

{

}

int songNumber[] = {1 2 3 4 5 6 7};
int songMinutes[] = {5 7 4 4 10 8 5};
int songSeconds [] = {10 42 19 33 27 55 0};
int timeSeconds[] = {10 52 11 44 11 6 6 };
int totalMinutes[] = {5 12 17 21 32 41 46};

{
totalMinutes = (usedMinutes+currentMinutes);
totalSeconds = (usedSeconds + currentSeconds);
}

No, it shouldn't be that:

#include <cstdlib>
#include <iostream>

using namespace std;

int main ()

{

}

int songNumber[] = {1 2 3 4 5 6 7};
int songMinutes[] = {5 7 4 4 10 8 5};
int songSeconds [] = {10 42 19 33 27 55 0};
int timeSeconds[] = {10 52 11 44 11 6 6 };
int totalMinutes[] = {5 12 17 21 32 41 46};

{
totalMinutes = (usedMinutes+currentMinutes);
totalSeconds = (usedSeconds + currentSeconds);
}

Lines 12 - 21 are just floating in the ether and there's nothing in main. Have you compiled this? What is the question?

Code tags. Please use them.

[code]

// place code here

[/code]


No, it shouldn't be that:

#include <cstdlib>
#include <iostream>

using namespace std;

int main ()

{

}

int songNumber[] = {1 2 3 4 5 6 7};
int songMinutes[] = {5 7 4 4 10 8 5};
int songSeconds [] = {10 42 19 33 27 55 0};
int timeSeconds[] = {10 52 11 44 11 6 6 };
int totalMinutes[] = {5 12 17 21 32 41 46};

{
totalMinutes = (usedMinutes+currentMinutes);
totalSeconds = (usedSeconds + currentSeconds);
}

Lines 12 - 21 are just floating in the ether and there's nothing in main. Have you compiled this? What is the question?

No i have not compiled it. I am at work right now
this is what i have to do
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. Write and design a C++ program to help you do this. The data are on the file songs.dat. The time is entered as seconds. For example, if a song takes 7 minutes and 42 seconds to play, the data entered in the data file for that songs would be 462.

After all the data has been read, the application should print a message indicating the time remaining on the CD.

The output should be in the form of a table with columns and headings written on a file. For example:

Song Song Time Total Time
Number Minutes Seconds Minutes Seconds
------- ------- ------- ------- -------
1 5 10 5 10
2 7 42 12 52
3 4 19 17 11
4 4 33 21 44
5 10 27 32 11
6 8 55 41 6
7 5 0 46 6

There are 33 minutes and 54 seconds of space left on the 80 minute CD.

Note that the output converts the input from seconds to minutes and seconds. Use meaningful variable names, proper indentation, and appropriate comments. Thoroughly test the program using your own data sets

Nikki!

You dont get the idea of this forum. Do you have any idea what you're talking about when you create a program?
You have to actually know c++ a little, to do anything. It doesnt look like you do. Make your program first, compile it, test it, compile it again until it works. IF there is any ERROR that you dont understand, please feel free to ask, but dont just write down what we tell you, with "Is this OK?" next to it...

You posted exactly what you posted in your first post, which was just some arrogant words, telling US to make a program for you? Good luck man...

commented: Well said. +11

Nikki!

You dont get the idea of this forum. Do you have any idea what you're talking about when you create a program?
You have to actually know c++ a little, to do anything. It doesnt look like you do. Make your program first, compile it, test it, compile it again until it works. IF there is any ERROR that you dont understand, please feel free to ask, but dont just write down what we tell you, with "Is this OK?" next to it...

You posted exactly what you posted in your first post, which was just some arrogant words, telling US to make a program for you? Good luck man...

Ditto.

You need to:

  1. Post your code in code tags.
  2. Compile as you go. Only post here when you get stuck.
  3. Ask a specific question rather than a verbatim homework dump.
  4. Be willing to put in the time and effort. And it takes A LOT of time and effort.

No one's going to do this for you.

Exactly.
I kinda forgot the time and effort part:

You need to put a LOT of time and effort into a project, or you'll never learn it. And if you don't want to learn it, you don't deserve to be a programmer...

OK sorry if I confused a lot of people with my post, but I only meant for you to remove the args, not to make the blank main function. Put the others lines back in the main function. It's much more conventional.

well thanks for all yr help

Is the problem solved?

is the problem solved?

well if i know what i was doing then i would not be asking for help. But thank you for yr time and help.

Please upvote the helpful posts. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.