You are on page 1of 2

EXP3_3

#include<iostream.h>
#include<conio.h>
class bday
{
public:
int day,month,year,m;
void accept()
{
cout<<"Day of Birth:\t";
cin>>day;
cout<<"Month of Birth:\t";
cin>>month;
cout<<"Year of Birth:\t";
cin>>year;
}
void display()
{
m=month;
if(year<1900||year>9999)
{
cout<<"\nInvalid Date";
}
else if(month>12||month<0)
{
cout<<"\nInvalid Date";
}
else if(month==1&&day<0||day>31)
{
cout<<"\nInvalid Date";
}
else if(month==2)
{
if(day<0||day>29&&year%4==0)
{
cout<<"\nInvalid Date";
}
else if(day<0||day>28&&year%4!=0)
{
cout<<"\nInvalid Date";
}
else
{
cout<<"\nDate of Birth\t"<<day<<":"<<m<<":"<<year;
}
}
else if(month==3&&day<0||day>31)
{
cout<<"\nInvalid Date";
}
else if(month==4&&day<0||day>30)
{
cout<<"\nInvalid Date";
}
else if(month==5&&day<0||day>30)
{
cout<<"\nInvalid Date";
}
else if(month==6&&day<0||day>30)
{
cout<<"\nInvalid Date";
Page 1

Print to PDF without this message by purchasing novaPDF (http://www.novapdf.com/)

EXP3_3
}
else if(month==7&&day<0||day>31)
{
cout<<"Invalid Date";
}
else if(month==8&&day<0||day>31)
{
cout<<"Invalid Date";
}
else if(month==9&&day<0||day>30)
{
cout<<"Invalid Date";
}
else if(month==10&&day<0||day>31)
{
cout<<"Invalid Date";
}
else if(month==11&&day<0||day>30)
{
cout<<"\nInvalid Date";
}
else if(month==12&&day<0||day>31)
{
cout<<"\nInvalid Date";
}
else
{
cout<<"\nDate of Birth:\t"<<day<<":"<<m<<":"<<year;
}
}
};
void main()
{
clrscr();
bday b;
b.accept();
b.display();
getch();
}

Page 2

Print to PDF without this message by purchasing novaPDF (http://www.novapdf.com/)