Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

8. Date Class Modification Modify the Date class in Programming Challenge 1 of Chapter 13. The new version should have the following overloaded operators: ++

8. Date Class Modification Modify the Date class in Programming Challenge 1 of Chapter 13. The new version should have the following overloaded operators: ++ Prefix and postfix increment operators. These operators should increment the objects day member. Prefix and postfix decrement operators. These operators should decrement the objects day member. - Subtractionoperator.IfoneDateobjectissubtractedfromanother,theoperatorshouldgive the number of days between the two dates. For example, if April 10, 2014 is subtracted from April 18, 2014, the result will be 8. 2 couts stream insertion operator. This operator should cause the date to the be displayed in the form April 18, 2014 cins stream extraction operator. This operator should prompt the user for a date to be stored in a Date object. The class should detect the following conditions and handle them accordingly: When a date is set to the last day of the month and incremented, it should become the first day of the following month. When a date is set to the December 31 and incremented, it should become January 1 of the fol- lowing year. When a day is set to the first day of the month and decremented, it should become the last day of the previous month. When a date is set to January 1 and decremented, it should become December 31 of the previous year. Demonstrate the classs capabilities in a simple program. Input Validation: The overloaded operator should not accept invalid dates. For example, the date 13/45/2014 should not be accepted. please help me base on this code // HW13_PC1 // YUNHAN.TU // 16/4/17 // 1 hour #include #include using namespace std; class data { private: int month; int day; int year; public: void setmonth(int m); void setday(int d); void setyear(int y); string mothform(int); void printdata1(); void printdata2(); void printdata3(); data () { month = 0; day = 0; year = 0; } //default data(int m,int d,int y) { month = m; day = d; year = y; } }; void data::setmonth(int m) { month = m; } void data::setday(int d) { day = d; } void data::setyear(int y) { year = y; } string data::mothform(int m) { string monthC; if (m == 1) monthC = "January"; else if (m==2) monthC ="Febrary"; else if (m == 3) monthC = "March"; else if (m == 4 ) monthC ="April"; else if (m == 5) monthC = "May"; else if (m ==6) monthC = "June"; else if (m ==7) monthC ="July"; else if (m == 8) monthC = "Auguest"; else if (m == 9) monthC = "septermber"; else if (m ==10) monthC = "october"; else if (m == 11) monthC = "November"; else monthC = "December"; return monthC; // a function that transfer number month to string month } void data::printdata1() { cout<>m; while(m >12 || m<1 ) { cout<<"the month number you enter is wrong please make sure it between 1-12"; cin>>m; } cout<<"Please enter the day: "<>d; while(d<1||d>31) { cout<<"he day number you enter is wrong please make sure it is between 1-31"; cin>>d; } cout<<"PLease enterh the year: "<>y; cin.ignore(); inputdata.setyear(y); inputdata.setday(d); inputdata.setmonth(m); inputdata.printdata1(); cout<

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions

Question

=+LO 10-1 Describe contemporary conflict.

Answered: 1 week ago