RoseNJ
Feb 26th, 2003, 09:56 PM
#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.
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.