write a c++ program Write a class Date that represents a date consisting of a year, month, and day. A Date class should have the following methods: # Date(int year, int month, int day) Constructs a new Date object to represent the given date. # void add(int &days) Moves this Date object forward by the given number of days. hint:* you should decide on the basis of month and year that given month ends 30,31,28,29 days.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

write a c++ program

Write a class Date that represents a date consisting of a year, month, and day. A Date class
should have the following methods:
# Date(int year, int month, int day)
Constructs a new Date object to represent the given date.
# void add(int &days)
Moves this Date object forward by the given number of days. hint:* you should decide
on the basis of month and year that given month ends 30,31,28,29 days.
# void add(int &month , int &days)

Moves this Date object forward by the given number of months and days. Months
should be within 1 to 12 and days in 1 to 31. For Example Date 2003/12/31and
add(1,29) =>Date will be 2004/02/29
# void add(Date & other)
Moves this Date object forward by the given Date.
# void addWeeks(int &weeks)
Moves this Date object forward by the given number of seven-day weeks.
# int daysTo(Date & other)
Returns the number of days that this Date must be adjusted to make it equal to the given
other Date.
# void subtract(int &days)
Moves this Date object backward by the given number of days. hint:* you should decide
on the basis of month and year that given month ends 30,31,28,29 days.
# void subtract(int &month , int &days)
Moves this Date object backward by the given number of months and days.
# void subtract (Date & other)
Moves this Date object backward by the given Date.
# int getDay()
Returns the day value of this date; for example, for the date 2006/07/22, returns 22.
# int getMonth()
Returns the month value of this date; for example, for the date
2006/07/22, returns 7.
# int getYear()
Returns the year value of this date; for example, for the date 2006/07/22, returns 2006.
# bool isLeapYear()
Returns true if the year of this date is a leap year. A leap year occurs every four years,
except for multiples of 100 that are not multiples of 400. For example, 1956, 1844,
1600, and 2000 are leap years, but 1983, 2002, 1700, and 1900 are not.
# String toString()
Returns a String representation of this date in year/month/day order, such as
"2006/07/22".

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY