#include <iostream>
using namespace std;
class age
{
private:
int day;
int mon;
int yer;
int day1;
int mon1;
int yer1;
public:
age():day(0),mon(0),yer(0), day1(0),mon1(0),yer1(0)
{}
void get()
{
cout<<"enter current date:"<<endl;
cin>>day;
cout<<"enter current month:"<<endl;
cin>>mon;
cout<<"enter current year:"<<endl;
cin>>yer;
cout<<"Enter your date of birth:"<<endl;
cin>>day1;
cout<<"Enter your month of birth:"<<endl;
cin>>mon1;
cout<<"Enter your year of birth:"<<endl;
cin>>yer1;
}
void print()
{
if(day>day1 && mon>mon1)
{
cout<<"your age is DD-MM-YYYY"<<endl;
cout<<day1-day<<"-"<<mon1- mon1<<"-"<<yer1-yer<<endl;
}
else if(day>day1 && mon<mon1)
cout<<day1-day<<"-"<<mon1- mon1<<"-"<<yer1-yer<<endl;
else if(day<day1 && mon<mon1)
cout<<cout<<(day+30)-day1<<"-" <<(mon+11)-mon1<<"-"<<(yer-1)- yer1<<endl;
}
};
void main()
{
age a;
a.get();
a.print();
}
No comments:
Post a Comment