A computer\'s time is giving in seconds from midnight. A administator needs a pr
ID: 3620075 • Letter: A
Question
A computer's time is giving in seconds from midnight. A administator needs a program to tell the time in military time. Write a program the asks for a time from midnight in seconds then outputs the time in hours, minutes and seconds.First create an algorithm, then write the program. Write the algorithm in a .txt file on onyx and submit it along with the program. The algorithm will be 20% of the grade.
Be sure that Program has comments in it that.
Sample execution:
Enter the seconds from midnight:26415
The time is 7:15:20.
Explanation / Answer
please rate - thanks I believe your example has minutes and seconds reversed #include <iostream>using namespace std;
int main()
{int seconds,hours,minutes;
cout<<"Enter the seconds from midnight: ";
cin>>seconds;
hours=seconds/3600;
seconds%=3600;
minutes=seconds/60;
seconds%=60;
cout<<"The time is "<<hours<<":"<<minutes<<":"<<seconds<<endl;
system("pause");
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.