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

/*you have correct this program which can increment in currentdate and add some

ID: 3616825 • Letter: #

Question

/*you have correct this program which can increment in currentdate and add some days in current date output of this program is Date: 26-12-2002 After adding 1 day, the date is Date: 27-12-2002
Date: 28-2-2000 After adding 5 days to the above date Date: 4-3-2000 */ #include<iostream.h> #include<conio.h> class date { private: int day, month, year; int daysOfMonth(date d); static const int daysInMonth[]; bool leapYear(int); public: date(int d=1, int m=1, int y=1990); void setDate(int, int, int); void display(); date operator ++(); date operator +(); }; void date::display() { cout<<" Date:"<<day<<"-"<<month<<"-"<<year; } date::date(int d, int m, int y) { setDate(d, m, y); } void date::setDate() { year=y; if(month<1 && month>12) month=1 else month=m if(month++2 && leapYear(y)) if(d>=1 && d<=29) day=d; else day=1; else if(d>=1 && d<=daysInMonth[month]) days=d; else days=1; } int date::daysOfMonth(date d) { if(d.month==2 && (leapYear(d.year)) return 29; else return daysInMonth[d.month]; } bool date::leapYear(int y) { if(y%400==0)||(y%100!=0 && y%4==0)) return true; else return false; } date date::operator +(int numberOfDays) { for(int i=0; i<=numberOfDays; i++) { ++(*this); } return *this; } date date::operator++() { if(day==daysOfMonth(*this) && month==12) { day=1; month=1; ++year; } else { if(day==daysOfMonth(*this)) { days=1; ++month; } else day++; } void main() { clrscr(); date d1(26,12,2002), d2(28,2,2000),d3; d1.display(); ++d1; cout<<" After adding 1 day, the date is"; d1.display(); cout<<endl; d2.display(); d2=d2+5; cout<<"After adding 5 days to the above date"; d2.display(); getch(); } /*you have correct this program which can increment in currentdate and add some days in current date output of this program is Date: 26-12-2002 After adding 1 day, the date is Date: 27-12-2002
Date: 28-2-2000 After adding 5 days to the above date Date: 4-3-2000 */ #include<iostream.h> #include<conio.h> class date { private: int day, month, year; int daysOfMonth(date d); static const int daysInMonth[]; bool leapYear(int); public: date(int d=1, int m=1, int y=1990); void setDate(int, int, int); void display(); date operator ++(); date operator +(); }; void date::display() { cout<<" Date:"<<day<<"-"<<month<<"-"<<year; } date::date(int d, int m, int y) { setDate(d, m, y); } void date::setDate() { year=y; if(month<1 && month>12) month=1 else month=m if(month++2 && leapYear(y)) if(d>=1 && d<=29) day=d; else day=1; else if(d>=1 && d<=daysInMonth[month]) days=d; else days=1; } int date::daysOfMonth(date d) { if(d.month==2 && (leapYear(d.year)) return 29; else return daysInMonth[d.month]; } bool date::leapYear(int y) { if(y%400==0)||(y%100!=0 && y%4==0)) return true; else return false; } date date::operator +(int numberOfDays) { for(int i=0; i<=numberOfDays; i++) { ++(*this); } return *this; } date date::operator++() { if(day==daysOfMonth(*this) && month==12) { day=1; month=1; ++year; } else { if(day==daysOfMonth(*this)) { days=1; ++month; } else day++; } void main() { clrscr(); date d1(26,12,2002), d2(28,2,2000),d3; d1.display(); ++d1; cout<<" After adding 1 day, the date is"; d1.display(); cout<<endl; d2.display(); d2=d2+5; cout<<"After adding 5 days to the above date"; d2.display(); getch(); }

Explanation / Answer

please rate - thanks I didn't know how to initialize an array in a class #include #include class date { private: int day, month, year; int daysOfMonth(date d); //static const int daysInMonth[12]; bool leapYear(int); public: date(int d=1, int m=1, int y=1990); void setDate(int, int, int); void display(); date operator ++(); date operator +(int); }; void date::display() { cout