Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Develop in C++ a class date to represent a calendar. The class should provide th

ID: 3866257 • Letter: D

Question

Develop in C++ a class date to represent a calendar. The class should provide the following operations: A default constructor that initializes a date object to 01-01-1900. A class constructor that initializes a date object to a correct value using three integer parameters corresponding to the desired month, day and year. The function toString () that returns the string version of a date object. For example, applying toString () to the date 12-01-2000 produces "December 1st, 2000". The function nextDate () that returns the successive date i.e. the new value of the date object. For example, applying nextDate () to the date 12-31-2000 produces a new date: 01-01-2001. You should take into account if the year is a leap year or not. A leap year is: (1) divisible by 400 or (2) divisible by 4 and not divisible by 100. The function compareDates () that checks if the date of interest is before, after or equal to the argument date.

Explanation / Answer

/*MydateClass.h – MyDate class definition*************you can learn from it and write a new code to avoid plagirism i used mydate class and at a time i have permision to solve 4 subparts only..but i can guide you more in comment

PLZ LET ME KNOW IF MY GUIDANCE HELPED U IN SOLVING PROBLEM .DO COMMENT & LIKE */

#include <iostream>

using std::cout;

using std::endl;

//declaration section

class MyDate

{

public:

MyDate();

MyDate(int,int,int);

void SetDate(int, int, int);

void DisplayDate();

void nextDate();

void compareDate(int day1,int month1,int year1,int day2,int month2,int year2 );

private:

int month;

int day;

int year;

};

//implementation section

MyDate::MyDate()

{

month = 01;

day = 01;

year = 1990;

} //end of default constructor

void MyDate::SetDate(int n1,int n2, int n3)

{

month = n1;

day = n2;

year = n3;

} //end of SetDate method

void MyDate::DisplayDate()

{

cout << month << "/" << day << "/" << year;

} //end of DisplayDate method

void MyDate::nextDate()

{

if (day == 31 && (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12))

{

if (month == 12)

{

day = 1;

year = year + 1;

}

else

{

day = 1;

month = month + 1;

}

}

if (day == 30 && (month ==4|| month == 6 || month == 9 || month == 11))

{

day = 1;

month = month + 1;

}

if (day == 28 && month == 2)

{

day = 1;

month = month + 1;

}

else

{

day = day + 1;

}

} //end of UpdateDate method

//Date.cpp – displays an item name and a quantity in inventory

int Mydate::int compareDate(int day1,int month1,int year1,int day2,int month2,int year2 )

{

if (year1 < year2)

return -1;//if second date is bigger

else if (year1 > year2)

return 1;//if first date is bigger

if (d1.year == d2.year)

{

if (month1<month2)

return -1;

else if (month1>month2)

return 1;

else if (day1<day2)

return -1;

else if(day1>day2)

return 1;

else

return 0;//if both date are same

}

}