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. Provide implementation of both functions in the class. Also modify your main function as follows:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

void Date: addDays (int n);

void Date: subtractDays(in n);

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.

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;
Transcribed Image Text: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;
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education