CHANGE-D-DATE


Submit solution

Points: 10
Time limit: 10.0s
Memory limit: 10M

Authors:
Problem type
Allowed languages
C++

Modify the above Date class by replacing the data member ddmmyyyy by 3 members: Int dd; Int mm; Int yyyy. Modify the member functions also as required.

Include the following member functions :

void add_year(int n) - add n years to the date, store the new date
void add_days(int n) - add n days to the date, store the new date
void add_month(int n) - add n months to date, store the new date

Also, modify the print_date() function to print_date(char c) that takes char c to print the date in DDcMMcYYYY format. E.g. if c is ‘/’ , print date in DD/MM/YYYY format.

Write a menu-driven C program that creates a Date object dobj and performs operations on it. Your program should repeatedly read a character from the user and do the following:

R - Read a date into dobj from the user using read_date()

S - Read 3 integers from the user and Set the dobj date using set_date()

C - Check whether the dobj holds a valid date. Print “VALID/INVALID”

P - read c and Print the dobj date in DDcMMcYYYY format

A - read d m y. Add d to date, m to month and y to years in dobj

X - Exit the program

INPUT SAMPLE:

R
12 04 2003
P
\
A
12
9
1
P
-
C
X

OUTPUT SAMPLE:

12\04\2003
24-01-2005
VALID

Comments

There are no comments at the moment.