C++ Project Name: IC08_TimeCalculator Write a program that asks the user to ente
ID: 3674183 • Letter: C
Question
C++ Project Name: IC08_TimeCalculator Write a program that asks the user to enter a number of seconds. • 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.
Explanation / Answer
#include <iostream>
using namespace std;
int main() {
// your code goes here
int sec,min=0,hours=0,day=0;
cout << "Enter a number of seconds" << endl;
cin >> sec;
min = (sec/60)%60;
hours = (sec/3600)%24;
day= sec/86400;
cout <<"Minutes : "<<min;
cout <<" Hours : "<<hours;
cout <<" Day : "<<day;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.