Problem

Using the classes extDateType (Programming Exercise) and dayType (Chapter 1, Programming E...

Using the classes extDateType (Programming Exercise) and dayType (Chapter 1, Programming Exercise), design the class calendarType so that, given the month and the year, we can print the calendar for that month. To print a monthly calendar, you must know the first day ofthe month and the number of days in that month. Thus, you must store the first day of the month, which is of the form dayType , and the month and the year of the calendar. Clearly, the month and the year can be stored in an object of the form extDateType by setting the day component of the date to 1, and the month and year as specified by the user. Thus, the class calendarType has two data members: an object of type dayType and an object of type extDateType .

Design the class calendarType so that the program can print a calendar for any month starting January 1, 1500. Note that the day for January 1 of the year 1500 is a Monday. To calculate the first day of a month, you can add the appropriate days to Monday of January 1, 1500.

For the class calendarType , include the following operations:

a. Determine the first day of the month for which the calendar will be printed. Call this operation firstDayOfMonth .

b. Set the month.

c. Set the year.

d. Return the month.

e. Return the year.

f. Print the calendar for the particular month.

g. Add the appropriate constructors to initialize the data members.

Programming Exercise

The class dateType defined in Programming Exercise prints the date in numerical form. Some applications might require the date to be printed in another form, such as March 24, 2003. Derive the class extDateType so that the date can be printed in either form.

Add a data member to the class extDateType so that the month can also be stored in string form. Add a function member to output the month in the string format followed by the year—for example, in the form March 2003.

Write the definitions of the functions to implement the operations for the class extDateType .

Programming Exercise

In this chapter, the class dateType was designed to implement the date in a program, but the member function setDate and the constructor do not check whether the date is valid before storing the date in the data members. Rewrite the definitions of the function setDate and the constructor so that the values for the month, day, and year are checked before storing the date into the data members. Add a function member, isLeapYear , to check whether a year is a leap year. Moreover, write a test program to test your class.

Programming Exercise

Write the definition of the class dayType that implements the day of the week in a program. The class dayType should store the day, such as Sunday for Sunday. The program should be able to perform the following operations on an object of type dayType :

a. Set the day.

b. Print the day.

c. Return the day.

d. Return the next day.

e. Return the previous day.

f. Calculate and return the day by adding certain days to the current day. For example, if the current day is Monday and we add 4 days, the day to be returned is Friday. Similarly, if today is Tuesday and we add 13 days, the day to be returned is Monday.

g. Add the appropriate constructors.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT