#include <iostream>
#include <string>
using namespace std;
class dateType
{
public:
dateType();
~dateType();
bool Checkdate();
bool isLeapYear();
void setDate();
void setMonth (int m);
int getMonth();
void setDay(int d);
int getDay();
void setYear (int y);
int getYear();
void Num_Month();
void Num_DayPassed();
void Num_RemainingYear();
void printdate();
private:
int month;
int day;
int year;
};
dateType::dateType()
{
cout<<"Object Created\n";
}
bool dateType::Checkdate()
{
if(year>=1900 && year<=9999)
{
if(month>=1&&month<=12)
{
if((day>=1&&day<=31)&&(month==1 ||month==3||month ==5||month==7||month ==8||month==10||month==12 ))
cout<<"Date is Valid.\n";
else if((day>=1 && day<=30) && (month==4 || month==6 || month==9 || month==11))
cout<<"Date is valid.\n";
else if((day>=1&&day<=28)&&(month==2))
cout<<"Date is Valid\n";
else
printf("Invalid Date.\n");
}
else
{
cout<<"Invalid Month.\n";
}
}
else
{
cout<<"Invalid Year.\n";
}
}
bool dateType::isLeapYear()
{
if (year % 4 == 0)
{
if (year % 100 == 0)
{
if (year % 400 == 0)
cout << year << " is a leap year.\n";
else
cout << year << " is not a leap year.\n";
}
else
cout << year << " is a leap year.\n";
}
else
cout << year << " is not a leap year.\n";
}
void dateType::setDate()
{
cout<<"Enter Month: ";
cin>>month;
cout<<endl;
cout<<"Enter Date: ";
cin>>day;
cout<<endl;
cout<<"Enter Year: ";
cin>>year;
cout<<endl;
}
void dateType::setMonth (int m)
{
month = m;
}
int dateType::getMonth()
{
return month;
}
void dateType::setDay(int d)
{
day=d;
}
int dateType::getDay()
{
return day;
}
void dateType:: setYear (int y)
{
year=y;
}
int dateType::getYear()
{
return year;
}
void dateType::Num_Month()
{
if (month ==4||month==6||month==9||month==11)
{day=30;
cout<<"Number of days in a month: "<<day<<endl;
}
else if (month ==2)
{
day=29;
cout<<"Number of days in a month: "<<day<<endl;
}
else
{
day=31;
cout<<"Number of days in a month: "<<day<<endl;
}
}
void dateType::Num_DayPassed()
{
int sum;
int yy = 365;
if (month ==1)
{
cout<<"Number of days Passed in the Year: "<<sum<<endl;
day=31;
sum=day-yy;
}
else if (month==2)
{
cout<<"Number of days Passed in the Year: "<<sum<<endl;
day=60;
sum=day-yy;
}
else if (month==3)
{
cout<<"Number of days Passed in the Year: "<<sum<<endl;
day=91;
sum=day-yy;
}
else if (month==4)
{
cout<<"Number of days Passed in the Year: "<<sum<<endl;
day=121;
sum=day-yy;
}
else if (month==5)
{
cout<<"Number of days Passed in the Year: "<<sum<<endl;
day=152;
sum=day-yy;
}
else if (month==6)
{
cout<<"Number of days Passed in the Year: "<<sum<<endl;
day=182;
sum=day-yy;
}
else if (month==7)
{
cout<<"Number of days Passed in the Year: "<<sum<<endl;
day=213;
sum=day-yy;
}
else if (month==8)
{
cout<<"Number of days Passed in the Year: "<<sum<<endl;
day=244;
sum=day-yy;
}
else if (month==9)
{
cout<<"Number of days Passed in the Year: "<<sum<<endl;
day=274;
sum=day-yy;
}
else if (month==10)
{
cout<<"Number of days Passed in the Year: "<<sum<<endl;
day=305;
sum=day-yy;
}
else if (month==11)
{
cout<<"Number of days Passed in the Year: "<<sum<<endl;
day=335;
sum=day-yy;
}
else if (month==12)
{
cout<<"Number of days Passed in the Year: "<<sum<<endl;
day=366;
sum=day-yy;
}
}
void dateType::Num_RemainingYear()
{
}
void dateType:: printdate()
{
cout<<"Month: "<<month<<endl;
cout<<"Date: "<<day<<endl;
cout<<"Year: "<<year<<endl;
}
dateType::~dateType()
{
cout<<"Object Deleted";
}
int main()
{
dateType dt;
dt.setDate();
dt.printdate();
dt.Checkdate();
dt.isLeapYear();
dt.Num_Month();
dt.Num_DayPassed();
return 0;
}