/*PROGRAM TO MAKE A CLASS AND CALCULATE SUM OF TWO GIVEN TIMES*/
#include<conio.h>
#include<iostream.h>
class time
{
int h,m,s;
public:
void input();
void output(time,time);
};
void time::input()
{
cout<<“Enter hours: “;
cin>>h;
cout<<“Enter minutes: “;
cin>>m;
cout<<“Enter seconds: “;
cin>>s;
}
void time::output(time t1,time t2)
{
int hr,min,sec,s1=0,m1=0;
cout<<“Time for first object is: “<<t1.h<<” hrs “<<t1.m<<” min “<<t1.s<<” sec “<<endl;
cout<<“Time for second object is: “<<t2.h<<” hrs “<<t2.m<<” min “<<t2.s<<” sec “<<endl;
sec=t1.s+t2.s;
while(sec>=60)
{
sec=sec-60;
s1++;
}
min=t1.m+t2.m+s1;
while(min>=60)
{
min=min-60;
m1++;
}
hr=t2.h+t1.h+m1;
cout<<“Toltal time is: “<<endl;
cout<<hr<<” hours “<<min<<” min “<<sec<<” sec”;
};
void main()
{
time t1,t2,t3;
clrscr();
cout<<“Enter time for first object:”<<endl;
t1.input();
cout<<“Enter time for second object:”<<endl;
t2.input();
t3.output(t1,t2);
getch();
}