Question 17. Program to find the duration time to do a task.

February 21, 2019
Question 17. Program to find the duration time to do a task.
#include "iostream"
using namespace std;
int main()
{
int Hrs = 0, Mins = 0, Sec = 0; //Starting Hours, Minutes and Seconds.
int Hrs1 = 0, Mins1 = 0, Sec1 = 0; //Ending Hours, Minutes and Seconds.
int HoD = 0, MoD = 0, SoD = 0; //Duration Hours, Minutes and Seconds.
cout << "Enter the Start time values\n";
cout << "Enter time Hours :";
cin >> Hrs;
cout << "Enter time Minutes:";
cin >> Mins;
cout << "Enter time Seconds:";
cin >> Sec;
cout << "Enter the End time values\n";
cout << "Enter time Hours :";
cin >> Hrs1;
cout << "Enter time Minutes:";
cin >> Mins1;
cout << "Enter time Seconds:";
cin >> Sec1;
if(Sec<=Sec1) //True case of IF statement for time Seconds.
{
SoD = Sec1 - Sec;
}
else //False case of IF statement for time Seconds.
{
Sec1=Sec1+60;
SoD = Sec1 - Sec;
Mins1=Mins1-1;}
if(Mins<=Mins1) //True case of IF statement for time Minnutes.
{
MoD = Mins1 - Mins;
}
else //False case of IF statement for time Minutes.
{
Mins1=Mins1+60;
MoD = Mins1 - Mins;
Hrs1= Hrs1-1;
}
HoD = Hrs1 - Hrs; // Calculations of time hours.
cout << "Total time Duration to commplete a task is="<<HoD<<":"<<MoD<<":"<<SoD;
return 0;
}

No comments:

'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();
Powered by Blogger.