|
-
Feb 26th, 2003, 10:56 PM
#1
Thread Starter
Member
Please help me
#include<iostream.h>
int main()
{
int S;
int m;
int s;
int time_left;
int sum;
int loopcount;
sum = 0;
loopcount = 1;
while(loopcount <=10)
{
{
sum = sum + loopcount;
loopcount ++;
}
cout <<"Please enter the song number:"<<endl;
cin >> S;
cout <<"Please enter the number of minutes:"<<endl;
cin >> m;
if (m > 45)
{
cout<<"Sorry the time is overload"<<endl;
}
else
{
cout <<"Please enter the number of seconds:"<<endl;
cin >> s;
}
cout <<"Song number "<< S <<", "<< m <<" minutes and "<< s <<" seconds"<<endl;
cout <<"Total time is "<< m <<" minutes and "<< s << " seconds. " <<endl;
cout <<"For the next song,"<<endl;
}
return 0;
}
given that the time can record on the tape is 45 minutes. The program tell us to input the song number and minutes and seconds.
This program ask us to using the while loop. If the song has more than 45 minutes then the output will be error. otherwise it will
look like this
output
Please enter the song number
1
Please enter the number of minutes
5
Please enter the number of seconds
45
song number is 1, 5 minutes and 45 seconds
Total time is 5 minutes and 45 seconds.
For the the next song,
Please enter the song number
2
Please enter the number of minutes
6
Please enter the number of seconds
15
song number is 1, 6 minutes and 15 seconds
Total time is 12 minutes and 0 seconds.
.
.
.
.
.
.
there are 3 minutes and 54 seconds of tape left.
-
Feb 27th, 2003, 07:07 AM
#2
You're using the deprecated headers.
Instead of
#include <iostream.h>
use
#include <iostream>
using namespace std;
Other than that, what's the point of your post? Does the program work or not? Where does it fail? Does it compile? What errors do you get?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 27th, 2003, 08:33 AM
#3
Thread Starter
Member
the program is not work like the way I want , Like the total time is not add up with the other song.
-
Feb 27th, 2003, 01:01 PM
#4
Frenzied Member
That's because you're inputting data into m each time, which overwrites it, so you should have an extra variable called total or something to add the inputted time to.
Also, you're nowhere adding the seconds to the minutes etc... you're missing lots of parts of code.
It's in general not a good idea to have 2 variables where only the case is different, this appraoch is likely to cause bugs and confuse you or the people who read your code.
This program shouldn't be too hard to make, just look careful at what you're doing... good luck!
oh and please, if you're posting code, post them between code tags, so that the indentation will be preserved... thanks
Last edited by Jop; Feb 27th, 2003 at 01:24 PM.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|