Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

create a structure called time.its three members ,all types int,should be called

ID: 3623397 • Letter: C

Question

create a structure called time.its three members ,all types int,should be called hours,minutes,and seconds.write a program that prompts the user to enter a time value in hours,minutes,and seconds.this can be in 12:59;59 format,or each number can be entered at a separate prompt("enter hours:",and so forth).the program should then store the time in a variable of type struct time,finally print out the total number of seconds represented by this time value:
long total secs=t1.hours*3600+t1.minutes*60+t1.seconds
use the time structure from above and make a program that obtains two time values from the user in 12:59:59 format,stores them in struct time variables,converts each one to seconds(type int0,adds these quantities,converts the results back to hours-minutes-seconds,stores the result in a time structure,and finally display the result in 12:59:59 format.

Explanation / Answer

please rate - thanks

#include <iostream>
#include <iomanip>
using namespace std;
struct digital_clock {
int hours;
int minutes;
int seconds;
};
void gettime(digital_clock);
int main ()
{digital_clock time1,time2;
gettime(time1);
gettime(time2);
system("pause");
return 0;
}
void gettime(digital_clock time)
{long s;
cout<<"Enter the time: ";
cout<<"Enter hour: ";
cin>>time.hours;
cout<<"Enter minutes: ";
cin>>time.minutes;
cout<<"enter seconds: ";
cin>>time.seconds;
s=time.hours*3600+time.minutes*60+time.seconds;
cout<<"The time you entered is "<<s<<" seconds"<<endl;
time.hours=s/3600;
s%=3600;
time.minutes=s/60;
time.seconds=s%60;
cout<<"The time is: "<<setw(2)<<setfill('0')<<time.hours<<":"
                      <<setw(2)<<setfill('0')<<time.minutes<<":"
                      <<setw(2)<<setfill('0')<<time.seconds<<endl<<endl;
}