//Header files #include<iostream> using namespace std; //function main program e
ID: 3626811 • Letter: #
Question
//Header files
#include<iostream>
using namespace std;
//function main program execution
int main()
{
//declare the variables
int hours, minutes, seconds, elapsedTime;
//let the user know about the program
cout << endl << " A program to display elapsed time in sec.";
//prompt the user to input elapsed time in HH:MM:SS
//prompt and read hours in time
cout << endl << " Enter elapsed time (hours) :";
cin >> minutes;
//calculate the elapsed time in seconds
//1 minute = 60 seconds
//1 hour = 60 minutes = 60 * 60 seconds
//1 hour = 3600 seconds
elapsedTime = (hours * 3600) + (minutes * 60 ) + seconds;
//print the elapsed time in seconds
cout << endl << " The elapsed time in seconds is"
<< elapsedTime;
system ("pause");
return 0;
}//end main
Explanation / Answer
#include<iostream>
using namespace std;
//function main program execution
int main()
{
//declare the variables
int hours, minutes, seconds, elapsedTime;
//let the user know about the program
cout << " A program to display elapsed time in sec.";
//prompt the user to input elapsed time in HH:MM:SS
//prompt and read hours in time
cout << " Enter hours of elapsed time :";
cin >> hours;
cout << " Enter minutes of elapsed time :";
cin >> minutes;
cout << " Enter secondss of elapsed time :";
cin >> seconds;
cout << " The Elapsed time u entered is "<< hours<<":"<<minutes<<":"<<seconds<<endl;
//calculate the elapsed time in seconds
//1 minute = 60 seconds
//1 hour = 60 minutes = 60 * 60 seconds
//1 hour = 3600 seconds
elapsedTime = (hours * 3600) + (minutes * 60 ) + seconds;
//print the elapsed time in seconds
cout << " The elapsed time in seconds is"<< elapsedTime<< endl ;
system ("pause");
return 0;
}//end main
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.