The addDays method will add n number of days to the current date that's stored in Object's data. For example, object hol
Posted: Sat May 21, 2022 8:52 am
The addDays method will add n number of days to the current date that's
stored in Object's data. For example, object hold 4/21/2022 as the date and if
user of this object calls addDays (10) method, it will add 10 days to
4/21/2022 giving a new date of 5/1/2022. There can be more complicated
scenarios if you add a lot of days (for example hundreds of days) due to
possible rollover of year and months. You can limit number of days to be
added to 100.
Just like addDays, subtractDays method will subtract number of days from
the current date.
void Date::addDays(int n);
void Date::substractDays(in n);
Provide implementation of both functions in the class. Also modify your
main function as follows:
int main() { std::cout << "Hello World!\n"; Date myDate(4, 21, 2022); myDate. showDate(); myDate.addDays(10); myDate. ShowDate(); myDate. subtractDays (9); myDate. showDate(); myDate. addDays (100); myDate. showDate(); myDate. subtractDays (100); myDate. showDate(); return 1;
stored in Object's data. For example, object hold 4/21/2022 as the date and if
user of this object calls addDays (10) method, it will add 10 days to
4/21/2022 giving a new date of 5/1/2022. There can be more complicated
scenarios if you add a lot of days (for example hundreds of days) due to
possible rollover of year and months. You can limit number of days to be
added to 100.
Just like addDays, subtractDays method will subtract number of days from
the current date.
void Date::addDays(int n);
void Date::substractDays(in n);
Provide implementation of both functions in the class. Also modify your
main function as follows:
int main() { std::cout << "Hello World!\n"; Date myDate(4, 21, 2022); myDate. showDate(); myDate.addDays(10); myDate. ShowDate(); myDate. subtractDays (9); myDate. showDate(); myDate. addDays (100); myDate. showDate(); myDate. subtractDays (100); myDate. showDate(); return 1;