Please make a comment for all the codes Or explain this prog


Please make a comment for all the codes
Or explain this program code!!
//Date.h

#ifndef DateFormat

#define DateFormat

#include <string>

using std::string;

class Date {

public:

Date();

Date( int, int );

Date( int, int, int );

Date( string, int, int );

void setDay11(int);

void setMonth11( int );

void print11() const;

void printDDDYYYY11( ) const;

void printMMDDYY11( ) const;

void printMonthDDYYYY11( ) const;

~Date();

private:

int month1;

int day1;

int year1;

int checkDay(int)const;

int daysInMonth(int)const;

bool isLeapYear()const;

int convertDDToDDD()const;

void setMMDDFromDDD(int);

string convertMMToMonth(int)const;

void setMMFromMonth(string);

int convertYYYYToYY()const;

void setYYYYFromYY(int);

};

#endif


//Main.cpp
include<iostream>

using std::cout;

using std::endl;

#include \"Date.h\"

int main()

{

Date date1( 252,1999 );

Date date2( 2,25,04 );

Date date3( \"September\", 1, 2000 );

Date date4;

date1.print11();

date2.print11();

date3.print11();

date4.print11();

cout << \'\ \';

date1.printDDDYYYY11();

date2.printDDDYYYY11();

date3.printDDDYYYY11();

date4.printDDDYYYY11();

cout << \'\ \';

date1.printMMDDYY11();

date2.printMMDDYY11();

date3.printMMDDYY11();

date4.printMMDDYY11();

cout << endl;

date1.printMonthDDYYYY11();

date2.printMonthDDYYYY11();

date3.printMonthDDYYYY11();

date4.printMonthDDYYYY11();

return 0;

}


//Date.cpp

#include <iostream>

using std::cout;

using std::endl;

#include<iomanip>

using std::setw;

using std::setfill;

include <ctime>

using std::time;

using std::localtime;

using std::tm;

using std::time_t;

#include \"Date.h\"

Date::Date()

{

struct tm *ptr;

time_t t1 = time( 0 );

ptr = localtime( &t1 );

day1 = ptr->tm_mday;

month1 = 1 + ptr->tm_mon;

year1 = ptr->tm_year + 1900;

}

Date::Date( int ddd1, int yyyy1 )

{

year1=yyyy1;

setMMDDFromDDD(ddd1);

}

Date::Date( int mm1, int dd1, int yy1 )

{

setYYYYFromYY( yy1 );
mm1 );

setDay11( dd1 );

}

Date::Date(string monthName2,int dd1,int yyyy1)

{

setMMFromMonth(monthName2);

setDay11(dd1);

year1=yyyy1;

}

void Date::setDay11( int d1 )

{

day1 = checkDay(d1); }

void Date::setMonth11( int m1 )

{

if(m1>0&& m1<=12)

month1=m1;

else

{

month1=1;

cout<<\"invalid month(\"<<m1<<\")set tol\ \";

}

}

void Date::print11()const

{

cout<<month1<<\"/\"<<day1<<\'/\'<<year1<<endl;

}

void Date::printDDDYYYY11()const

{

cout<<convertDDToDDD()<<\' \'<<year1<<endl;

}

void Date::printMMDDYY11()const

{

cout<<setw(2)<<setfill(\'0\')<<month1<<\'/\'<<setw(2)<<setfill(\'0\')<<day1<<setw(2)<<setfill(\'0\')<<convertYYYYToYY()<<endl;

}

void Date::printMonthDDYYYY11()const

{

cout<<convertMMToMonth(month1)<<\' \'<<day1<<\",\"<<year1<<endl;
}

Date::~Date()

{

cout<<\"date object destructor for date\";

print11();

cout<<endl;

}

int Date::checkDay(int testDay)const

{

if(testDay>0 && testDay<=daysInMonth(month1))

return testDay;

if(month1==2 && testDay==29 && isLeapYear())

return testDay;

cout<<\"invalid day(\"<<testDay<<\")set to 1\ \";

return 1;

}

int Date::daysInMonth( int m ) const

{

if(isLeapYear()&&m==2)

return 29;

static const int daysPerMonth1[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

return daysPerMonth1[m];

}

bool Date::isLeapYear()const

{

if ( year1 % 400 == 0 || ( year1 % 4 == 0 && year1 % 100 != 0 ) )
return true;

else

return false;

}



int Date::convertDDToDDD() const

{

int ddd1 = 0;

for(int i=1;i<month1;i++)

ddd1+=daysInMonth(i);

ddd1+=day1;

return ddd1;

}

void Date::setMMDDFromDDD(int ddd1)

{

int dayTotal1=0;

int m;

for(m=1;m<=2&&(dayTotal1+daysInMonth(m))<ddd1;m++)

dayTotal1+=daysInMonth(m);

setMonth11(m);

setDay11(ddd1-dayTotal1);

}

string Date::convertMMToMonth(int mm)const
{

static const string months1[]={\" \",\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"december\"};

return months1[mm];

}

void Date::setMMFromMonth(string m1)

{

bool matchFound=false;

for(int k=1;k<=12&&!matchFound;k++)

{

string tempMonth1=convertMMToMonth(k);

if(tempMonth1==m1)

{

setMonth11(k);

matchFound=true;

}

}

if(!matchFound)

{

cout<<\"invalid month name(\"<<month1<<\")month set to 1\ \";

setMonth11(1);

}

}

int Date::convertYYYYToYY()const

{

return (year1>=2000?year1-2000:year1-1900);

}

void Date::setYYYYFromYY(int yy)

{

year1=(yy<7?yy+2000:yy+1900);

}

Please make a comment for all the codes
Or explain this program code!!
//Date.h

#ifndef DateFormat

#define DateFormat

#include <string>

using std::string;

class Date {

public:

Date();

Date( int, int );

Date( int, int, int );

Date( string, int, int );

void setDay11(int);

void setMonth11( int );

void print11() const;

void printDDDYYYY11( ) const;

void printMMDDYY11( ) const;

void printMonthDDYYYY11( ) const;

~Date();

private:

int month1;

int day1;

int year1;

int checkDay(int)const;

int daysInMonth(int)const;

bool isLeapYear()const;

int convertDDToDDD()const;

void setMMDDFromDDD(int);

string convertMMToMonth(int)const;

void setMMFromMonth(string);

int convertYYYYToYY()const;

void setYYYYFromYY(int);

};

#endif


//Main.cpp
include<iostream>

using std::cout;

using std::endl;

#include \"Date.h\"

int main()

{

Date date1( 252,1999 );

Date date2( 2,25,04 );

Date date3( \"September\", 1, 2000 );

Date date4;

date1.print11();

date2.print11();

date3.print11();

date4.print11();

cout << \'\ \';

date1.printDDDYYYY11();

date2.printDDDYYYY11();

date3.printDDDYYYY11();

date4.printDDDYYYY11();

cout << \'\ \';

date1.printMMDDYY11();

date2.printMMDDYY11();

date3.printMMDDYY11();

date4.printMMDDYY11();

cout << endl;

date1.printMonthDDYYYY11();

date2.printMonthDDYYYY11();

date3.printMonthDDYYYY11();

date4.printMonthDDYYYY11();

return 0;

}


//Date.cpp

#include <iostream>

using std::cout;

using std::endl;

#include<iomanip>

using std::setw;

using std::setfill;

include <ctime>

using std::time;

using std::localtime;

using std::tm;

using std::time_t;

#include \"Date.h\"

Date::Date()

{

struct tm *ptr;

time_t t1 = time( 0 );

ptr = localtime( &t1 );

day1 = ptr->tm_mday;

month1 = 1 + ptr->tm_mon;

year1 = ptr->tm_year + 1900;

}

Date::Date( int ddd1, int yyyy1 )

{

year1=yyyy1;

setMMDDFromDDD(ddd1);

}

Date::Date( int mm1, int dd1, int yy1 )

{

setYYYYFromYY( yy1 );
mm1 );

setDay11( dd1 );

}

Date::Date(string monthName2,int dd1,int yyyy1)

{

setMMFromMonth(monthName2);

setDay11(dd1);

year1=yyyy1;

}

void Date::setDay11( int d1 )

{

day1 = checkDay(d1); }

void Date::setMonth11( int m1 )

{

if(m1>0&& m1<=12)

month1=m1;

else

{

month1=1;

cout<<\"invalid month(\"<<m1<<\")set tol\ \";

}

}

void Date::print11()const

{

cout<<month1<<\"/\"<<day1<<\'/\'<<year1<<endl;

}

void Date::printDDDYYYY11()const

{

cout<<convertDDToDDD()<<\' \'<<year1<<endl;

}

void Date::printMMDDYY11()const

{

cout<<setw(2)<<setfill(\'0\')<<month1<<\'/\'<<setw(2)<<setfill(\'0\')<<day1<<setw(2)<<setfill(\'0\')<<convertYYYYToYY()<<endl;

}

void Date::printMonthDDYYYY11()const

{

cout<<convertMMToMonth(month1)<<\' \'<<day1<<\",\"<<year1<<endl;
}

Date::~Date()

{

cout<<\"date object destructor for date\";

print11();

cout<<endl;

}

int Date::checkDay(int testDay)const

{

if(testDay>0 && testDay<=daysInMonth(month1))

return testDay;

if(month1==2 && testDay==29 && isLeapYear())

return testDay;

cout<<\"invalid day(\"<<testDay<<\")set to 1\ \";

return 1;

}

int Date::daysInMonth( int m ) const

{

if(isLeapYear()&&m==2)

return 29;

static const int daysPerMonth1[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

return daysPerMonth1[m];

}

bool Date::isLeapYear()const

{

if ( year1 % 400 == 0 || ( year1 % 4 == 0 && year1 % 100 != 0 ) )
return true;

else

return false;

}



int Date::convertDDToDDD() const

{

int ddd1 = 0;

for(int i=1;i<month1;i++)

ddd1+=daysInMonth(i);

ddd1+=day1;

return ddd1;

}

void Date::setMMDDFromDDD(int ddd1)

{

int dayTotal1=0;

int m;

for(m=1;m<=2&&(dayTotal1+daysInMonth(m))<ddd1;m++)

dayTotal1+=daysInMonth(m);

setMonth11(m);

setDay11(ddd1-dayTotal1);

}

string Date::convertMMToMonth(int mm)const
{

static const string months1[]={\" \",\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"december\"};

return months1[mm];

}

void Date::setMMFromMonth(string m1)

{

bool matchFound=false;

for(int k=1;k<=12&&!matchFound;k++)

{

string tempMonth1=convertMMToMonth(k);

if(tempMonth1==m1)

{

setMonth11(k);

matchFound=true;

}

}

if(!matchFound)

{

cout<<\"invalid month name(\"<<month1<<\")month set to 1\ \";

setMonth11(1);

}

}

int Date::convertYYYYToYY()const

{

return (year1>=2000?year1-2000:year1-1900);

}

void Date::setYYYYFromYY(int yy)

{

year1=(yy<7?yy+2000:yy+1900);

}

Please make a comment for all the codes
Or explain this program code!!
//Date.h

#ifndef DateFormat

#define DateFormat

#include <string>

using std::string;

class Date {

public:

Date();

Date( int, int );

Date( int, int, int );

Date( string, int, int );

void setDay11(int);

void setMonth11( int );

void print11() const;

void printDDDYYYY11( ) const;

void printMMDDYY11( ) const;

void printMonthDDYYYY11( ) const;

~Date();

private:

int month1;

int day1;

int year1;

int checkDay(int)const;

int daysInMonth(int)const;

bool isLeapYear()const;

int convertDDToDDD()const;

void setMMDDFromDDD(int);

string convertMMToMonth(int)const;

void setMMFromMonth(string);

int convertYYYYToYY()const;

void setYYYYFromYY(int);

};

#endif


//Main.cpp
include<iostream>

using std::cout;

using std::endl;

#include \"Date.h\"

int main()

{

Date date1( 252,1999 );

Date date2( 2,25,04 );

Date date3( \"September\", 1, 2000 );

Date date4;

date1.print11();

date2.print11();

date3.print11();

date4.print11();

cout << \'\ \';

date1.printDDDYYYY11();

date2.printDDDYYYY11();

date3.printDDDYYYY11();

date4.printDDDYYYY11();

cout << \'\ \';

date1.printMMDDYY11();

date2.printMMDDYY11();

date3.printMMDDYY11();

date4.printMMDDYY11();

cout << endl;

date1.printMonthDDYYYY11();

date2.printMonthDDYYYY11();

date3.printMonthDDYYYY11();

date4.printMonthDDYYYY11();

return 0;

}


//Date.cpp

#include <iostream>

using std::cout;

using std::endl;

#include<iomanip>

using std::setw;

using std::setfill;

include <ctime>

using std::time;

using std::localtime;

using std::tm;

using std::time_t;

#include \"Date.h\"

Date::Date()

{

struct tm *ptr;

time_t t1 = time( 0 );

ptr = localtime( &t1 );

day1 = ptr->tm_mday;

month1 = 1 + ptr->tm_mon;

year1 = ptr->tm_year + 1900;

}

Date::Date( int ddd1, int yyyy1 )

{

year1=yyyy1;

setMMDDFromDDD(ddd1);

}

Date::Date( int mm1, int dd1, int yy1 )

{

setYYYYFromYY( yy1 );
include<iostream>

using std::cout;

using std::endl;

#include \"Date.h\"

int main()

{

Date date1( 252,1999 );

Date date2( 2,25,04 );

Date date3( \"September\", 1, 2000 );

Date date4;

date1.print11();

date2.print11();

date3.print11();

date4.print11();

cout << \'\ \';

date1.printDDDYYYY11();

date2.printDDDYYYY11();

date3.printDDDYYYY11();

date4.printDDDYYYY11();

cout << \'\ \';

date1.printMMDDYY11();

date2.printMMDDYY11();

date3.printMMDDYY11();

date4.printMMDDYY11();

cout << endl;

date1.printMonthDDYYYY11();

date2.printMonthDDYYYY11();

date3.printMonthDDYYYY11();

date4.printMonthDDYYYY11();

return 0;

}


//Date.cpp

#include <iostream>

using std::cout;

using std::endl;

#include<iomanip>

using std::setw;

using std::setfill;

include <ctime>

using std::time;

using std::localtime;

using std::tm;

using std::time_t;

#include \"Date.h\"

Date::Date()

{

struct tm *ptr;

time_t t1 = time( 0 );

ptr = localtime( &t1 );

day1 = ptr->tm_mday;

month1 = 1 + ptr->tm_mon;

year1 = ptr->tm_year + 1900;

}

Date::Date( int ddd1, int yyyy1 )

{

year1=yyyy1;

setMMDDFromDDD(ddd1);

}

Date::Date( int mm1, int dd1, int yy1 )

{

setYYYYFromYY( yy1 );
include <ctime>

using std::time;

using std::localtime;

using std::tm;

using std::time_t;

#include \"Date.h\"

Date::Date()

{

struct tm *ptr;

time_t t1 = time( 0 );

ptr = localtime( &t1 );

day1 = ptr->tm_mday;

month1 = 1 + ptr->tm_mon;

year1 = ptr->tm_year + 1900;

}

Date::Date( int ddd1, int yyyy1 )

{

year1=yyyy1;

setMMDDFromDDD(ddd1);

}

Date::Date( int mm1, int dd1, int yy1 )

{

setYYYYFromYY( yy1 );
mm1 );

setDay11( dd1 );

}

Date::Date(string monthName2,int dd1,int yyyy1)

{

setMMFromMonth(monthName2);

setDay11(dd1);

year1=yyyy1;

}

void Date::setDay11( int d1 )

{

day1 = checkDay(d1); }

void Date::setMonth11( int m1 )

{

if(m1>0&& m1<=12)

month1=m1;

else

{

month1=1;

cout<<\"invalid month(\"<<m1<<\")set tol\ \";

}

}

void Date::print11()const

{

cout<<month1<<\"/\"<<day1<<\'/\'<<year1<<endl;

}

void Date::printDDDYYYY11()const

{

cout<<convertDDToDDD()<<\' \'<<year1<<endl;

}

void Date::printMMDDYY11()const

{

cout<<setw(2)<<setfill(\'0\')<<month1<<\'/\'<<setw(2)<<setfill(\'0\')<<day1<<setw(2)<<setfill(\'0\')<<convertYYYYToYY()<<endl;

}

void Date::printMonthDDYYYY11()const

{

cout<<convertMMToMonth(month1)<<\' \'<<day1<<\",\"<<year1<<endl;
mm1 );

setDay11( dd1 );

}

Date::Date(string monthName2,int dd1,int yyyy1)

{

setMMFromMonth(monthName2);

setDay11(dd1);

year1=yyyy1;

}

void Date::setDay11( int d1 )

{

day1 = checkDay(d1); }

void Date::setMonth11( int m1 )

{

if(m1>0&& m1<=12)

month1=m1;

else

{

month1=1;

cout<<\"invalid month(\"<<m1<<\")set tol\ \";

}

}

void Date::print11()const

{

cout<<month1<<\"/\"<<day1<<\'/\'<<year1<<endl;

}

void Date::printDDDYYYY11()const

{

cout<<convertDDToDDD()<<\' \'<<year1<<endl;

}

void Date::printMMDDYY11()const

{

cout<<setw(2)<<setfill(\'0\')<<month1<<\'/\'<<setw(2)<<setfill(\'0\')<<day1<<setw(2)<<setfill(\'0\')<<convertYYYYToYY()<<endl;

}

void Date::printMonthDDYYYY11()const

{

cout<<convertMMToMonth(month1)<<\' \'<<day1<<\",\"<<year1<<endl;
}

Date::~Date()

{

cout<<\"date object destructor for date\";

print11();

cout<<endl;

}

int Date::checkDay(int testDay)const

{

if(testDay>0 && testDay<=daysInMonth(month1))

return testDay;

if(month1==2 && testDay==29 && isLeapYear())

return testDay;

cout<<\"invalid day(\"<<testDay<<\")set to 1\ \";

return 1;

}

int Date::daysInMonth( int m ) const

{

if(isLeapYear()&&m==2)

return 29;

static const int daysPerMonth1[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

return daysPerMonth1[m];

}

bool Date::isLeapYear()const

{

if ( year1 % 400 == 0 || ( year1 % 4 == 0 && year1 % 100 != 0 ) )
return true;

else

return false;

}



int Date::convertDDToDDD() const

{

int ddd1 = 0;

for(int i=1;i<month1;i++)

ddd1+=daysInMonth(i);

ddd1+=day1;

return ddd1;

}

void Date::setMMDDFromDDD(int ddd1)

{

int dayTotal1=0;

int m;

for(m=1;m<=2&&(dayTotal1+daysInMonth(m))<ddd1;m++)

dayTotal1+=daysInMonth(m);

setMonth11(m);

setDay11(ddd1-dayTotal1);

}

string Date::convertMMToMonth(int mm)const
}

Date::~Date()

{

cout<<\"date object destructor for date\";

print11();

cout<<endl;

}

int Date::checkDay(int testDay)const

{

if(testDay>0 && testDay<=daysInMonth(month1))

return testDay;

if(month1==2 && testDay==29 && isLeapYear())

return testDay;

cout<<\"invalid day(\"<<testDay<<\")set to 1\ \";

return 1;

}

int Date::daysInMonth( int m ) const

{

if(isLeapYear()&&m==2)

return 29;

static const int daysPerMonth1[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

return daysPerMonth1[m];

}

bool Date::isLeapYear()const

{

if ( year1 % 400 == 0 || ( year1 % 4 == 0 && year1 % 100 != 0 ) )
return true;

else

return false;

}



int Date::convertDDToDDD() const

{

int ddd1 = 0;

for(int i=1;i<month1;i++)

ddd1+=daysInMonth(i);

ddd1+=day1;

return ddd1;

}

void Date::setMMDDFromDDD(int ddd1)

{

int dayTotal1=0;

int m;

for(m=1;m<=2&&(dayTotal1+daysInMonth(m))<ddd1;m++)

dayTotal1+=daysInMonth(m);

setMonth11(m);

setDay11(ddd1-dayTotal1);

}

string Date::convertMMToMonth(int mm)const
return true;

else

return false;

}



int Date::convertDDToDDD() const

{

int ddd1 = 0;

for(int i=1;i<month1;i++)

ddd1+=daysInMonth(i);

ddd1+=day1;

return ddd1;

}

void Date::setMMDDFromDDD(int ddd1)

{

int dayTotal1=0;

int m;

for(m=1;m<=2&&(dayTotal1+daysInMonth(m))<ddd1;m++)

dayTotal1+=daysInMonth(m);

setMonth11(m);

setDay11(ddd1-dayTotal1);

}

string Date::convertMMToMonth(int mm)const
{

static const string months1[]={\" \",\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"december\"};

return months1[mm];

}

void Date::setMMFromMonth(string m1)

{

bool matchFound=false;

for(int k=1;k<=12&&!matchFound;k++)

{

string tempMonth1=convertMMToMonth(k);

if(tempMonth1==m1)

{

setMonth11(k);

matchFound=true;

}

}

if(!matchFound)

{

cout<<\"invalid month name(\"<<month1<<\")month set to 1\ \";

setMonth11(1);

}

}

int Date::convertYYYYToYY()const

{

return (year1>=2000?year1-2000:year1-1900);

}

void Date::setYYYYFromYY(int yy)

{

year1=(yy<7?yy+2000:yy+1900);

}
{

static const string months1[]={\" \",\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"december\"};

return months1[mm];

}

void Date::setMMFromMonth(string m1)

{

bool matchFound=false;

for(int k=1;k<=12&&!matchFound;k++)

{

string tempMonth1=convertMMToMonth(k);

if(tempMonth1==m1)

{

setMonth11(k);

matchFound=true;

}

}

if(!matchFound)

{

cout<<\"invalid month name(\"<<month1<<\")month set to 1\ \";

setMonth11(1);

}

}

int Date::convertYYYYToYY()const

{

return (year1>=2000?year1-2000:year1-1900);

}

void Date::setYYYYFromYY(int yy)

{

year1=(yy<7?yy+2000:yy+1900);

}

Solution

//Date.h

#ifndef DateFormat
#define DateFormat
#include <string>
using std::string;

class Date {

   public:
   // constructor
   Date();
   // parameterized consturctors
   Date( int, int );
   Date( int, int, int );
   Date( string, int, int );
   // setters
   void setDay11(int);
   void setMonth11( int );
   // print functions
   void print11() const;
   void printDDDYYYY11( ) const;
   void printMMDDYY11( ) const;
   void printMonthDDYYYY11( ) const;
   ~Date();

   private:
   // variables
   int month1;
   int day1;
   int year1;
   // check valid day
   int checkDay(int)const;
   // count days in month
   int daysInMonth(int)const;
   // check leap year
   bool isLeapYear()const;
   // converter function
   int convertDDToDDD()const;
   // setter
   void setMMDDFromDDD(int);
   // converter function
   string convertMMToMonth(int)const;
   // setter
   void setMMFromMonth(string);
   // converter function
   int convertYYYYToYY()const;
   // setter
   void setYYYYFromYY(int);

};

#endif

//Date.cpp

// input output library
#include <iostream>
using std::cout;
using std::endl;
// library to set width and fill
#include <iomanip>
using std::setw;
using std::setfill;
// library to use time
#include <ctime>
using std::time;
using std::localtime;
using std::tm;
using std::time_t;
#include \"Date.h\"

// default constructor
Date::Date()
{
    // taking pointer to tm
    struct tm *ptr;
    // set time as 0
    time_t t1 = time( 0 );
    // pointer taking address of t1
    ptr = localtime( &t1 );
    // day1 holds the day value of ptr
    day1 = ptr->tm_mday;
    // month1 holds the month value of ptr
    month1 = 1 + ptr->tm_mon;
    // year1 holds the year value of ptr + 1900
    year1 = ptr->tm_year + 1900;

}

// parameterized constructor
Date::Date( int ddd1, int yyyy1 )
{
    // set year
    year1=yyyy1;
    // call the month from date function
    setMMDDFromDDD(ddd1);
}

// parameterized constructor
Date::Date( int mm1, int dd1, int yy1 )
{
// call the year from year function
setYYYYFromYY( yy1 );
// set day function
setDay11( dd1 );
}

// parameterized constructor
Date::Date(string monthName2,int dd1,int yyyy1)
{
// call the month from month function
setMMFromMonth(monthName2);
// setday
setDay11(dd1);
year1=yyyy1;
}

void Date::setDay11( int d1 )
{
    // check for valid day and set it
    day1 = checkDay(d1);
}

void Date::setMonth11( int m1 )
{
    // check for valid month and set it
    if(m1>0&& m1<=12)
        month1=m1;
    else
    {
        // end set month to 1
        month1=1;
        cout<<\"invalid month(\"<<m1<<\")set to 1\ \";
    }

}

// print function
void Date::print11()const
{
    cout<<month1<<\"/\"<<day1<<\'/\'<<year1<<endl;
}
void Date::printDDDYYYY11()const
{
    cout<<convertDDToDDD()<<\' \'<<year1<<endl;
}

void Date::printMMDDYY11()const
{
    // print in specific format, 2 width, fill 0
    cout<<setw(2)<<setfill(\'0\')<<month1<<\'/\'<<setw(2)<<setfill(\'0\')<<day1<<setw(2)<<setfill(\'0\')<<convertYYYYToYY()<<endl;
}

void Date::printMonthDDYYYY11()const
{
    cout<<convertMMToMonth(month1)<<\' \'<<day1<<\",\"<<year1<<endl;
}

// date destructor
Date::~Date()
{
    cout<<\"date object destructor for date\";
    print11();
    cout<<endl;
}

// check if day is valid
int Date::checkDay(int testDay)const
{
    if(testDay>0 && testDay<=daysInMonth(month1))
        return testDay;
    if(month1==2 && testDay==29 && isLeapYear())
        return testDay;
    cout<<\"invalid day(\"<<testDay<<\")set to 1\ \";
    return 1;

}

// count and return number of days in month
int Date::daysInMonth( int m ) const
{
    if(isLeapYear()&&m==2)
    return 29;
    static const int daysPerMonth1[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    return daysPerMonth1[m];

}

// check for leap year
bool Date::isLeapYear()const
{

    if ( year1 % 400 == 0 || ( year1 % 4 == 0 && year1 % 100 != 0 ) )
        return true;
    else
        return false;
}

// date converter function
int Date::convertDDToDDD() const
{

    int ddd1 = 0;
    for(int i=1;i<month1;i++)
    ddd1+=daysInMonth(i);
    ddd1+=day1;
    return ddd1;

}

// setting month day from day
void Date::setMMDDFromDDD(int ddd1)
{
    int dayTotal1=0;
    int m;
    // iterate months and check if total days plus month days is less than ddd1
    for(m=1;m<=2&&(dayTotal1+daysInMonth(m))<ddd1;m++)
    dayTotal1+=daysInMonth(m);
    // set month
    setMonth11(m);
    // set day
    setDay11(ddd1-dayTotal1);
}

// convert given month number to corresponding month name
string Date::convertMMToMonth(int mm)const
{
    static const string months1[]={\" \",\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"december\"};
    return months1[mm];

}

// set month function
void Date::setMMFromMonth(string m1)
{

    bool matchFound=false;
    // check for month match
    for(int k=1;k<=12&&!matchFound;k++)
    {
    string tempMonth1=convertMMToMonth(k);
    if(tempMonth1==m1)
    {
        // set month if match is found
    setMonth11(k);
    matchFound=true;
    }
    }
    // else set month to 1
    if(!matchFound)
    {
    cout<<\"invalid month name(\"<<month1<<\")month set to 1\ \";
    setMonth11(1);
    }

}

// year converter
int Date::convertYYYYToYY()const
{
    return (year1>=2000?year1-2000:year1-1900);
}

// other yer converter function
void Date::setYYYYFromYY(int yy)
{
    year1=(yy<7?yy+2000:yy+1900);
}


//Main.cpp

// input output library
#include <iostream>
using std::cout;
using std::endl;
#include \"Date.h\"

int main()
{
// calling parameterized constructors
Date date1( 252,1999 );
Date date2( 2,25,04 );
Date date3( \"September\", 1, 2000 );

// print dates
Date date4;
date1.print11();
date2.print11();
date3.print11();
date4.print11();

// print date to years
cout << \'\ \';
date1.printDDDYYYY11();
date2.printDDDYYYY11();
date3.printDDDYYYY11();
date4.printDDDYYYY11();

// print month to date to years
cout << \'\ \';
date1.printMMDDYY11();
date2.printMMDDYY11();
date3.printMMDDYY11();
date4.printMMDDYY11();

// print final dates
cout << endl;
date1.printMonthDDYYYY11();
date2.printMonthDDYYYY11();
date3.printMonthDDYYYY11();
date4.printMonthDDYYYY11();

return 0;

}


/*
output:

invalid day(193)set to 1
3/1/1999
3/25/2004
9/1/2000
10/11/2016

60 1999
85 2004
245 2000
285 2016

03/0199
03/2504
09/0100
10/1116

March 1,1999
March 25,2004
September 1,2000
October 11,2016
date object destructor for date10/11/2016

date object destructor for date9/1/2000

date object destructor for date3/25/2004

date object destructor for date3/1/1999

*/

 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string
 Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include <string> using std::string

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site