Write a program that ask the user to enter a number of seconds 15 Times.
There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes in that many seconds.
There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or equal to 3,600, the program should display the number of hours in that many seconds.
There are 86,400 seconds in a day. if the number of seconds entered by the user is greater than or equal to 86,400, the program should display the number of days in that many seconds.
Instructions:
60*60*24 == Day
3989
7422 - 3600 1 day== 3822 -3600 2 day = 222 3.7
86401 = 1 Day and 1 Second
2700 = 45 minutes
2520 = 42 Minutes
1989/60 = 33.5 Minutes
if(number > 60 && number < 3600)
number / 60 == Minutes
else if(number > 3600 && number < 86400)
3989 - 3600 = 389 == 1 Day and 6.44 minutes
7422 // 2 Days and 3.7 Minutes
1
Expert's answer
2013-05-09T08:24:11-0400
//There are 60 seconds in a minute. If the number of seconds entered by the user is greater than // or equal to 60, the program should display the number of minutes in that many seconds. //There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than //or equal to 3,600, the program should display the number of hours in that many seconds. //There are 86,400 seconds in a day. if the number of seconds entered by the user is greater than //or equal to 86,400, the program should display the number of days in that many seconds.
#include <iostream> #include <string> #include <list> using namespace std;
int main(){
long time=0; int day=0; int hour=0; int min=0;
cout<<"Enter time in sec:"; cin>>time; if(time / 86400 !=0)& { day = time / 86400; time = time % 86400; } if (time / 3600 != 0 ) {hour = time / 3600; time =time % 3600; } if (time / 60 != 0 ) {min = time / 60; time =time % 60; }
cout<<"It is "<<day<<" days "<<hour<<" hours "<<min<<" minutes\n";
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment