#include<iostream.h>
#include<conio.h>
class timex {
public:
int hours;
int min;
int seconds;
timex(int h,int m,int s)
{
hours=h;
min=m;
seconds=s;
}
void access(){
cout<<"hours : "<<hours;
cout<<" minutes : "<<min;
cout<<" seconds : "<<seconds;
}
void advance(int w,int r,int m){ int a,b,c,e;
cout<<endl<<"enter your hour advance:"; cin>>a;
cout<<endl<<"enter your minutes advance:"; cin>>b;
cout<<endl<<"enter your seconds advance:"; cin>>c;
hours=hours+a; min=min+b; seconds=seconds+c;
if(hours>12)
{
hours=hours%12;
}
if(min>=60)
{ e=min/60; min=min%60; hours=hours+e;
}
if(seconds>=60)
{ e=seconds/60;
min=min+e;
seconds=seconds%60;} }
};
int main()
{
timex s(12,34,23);
int z,x,v;
s.access();
s.advance(z,x,v);
s.access();
getch();
}
like this program
ReplyDelete