In this project, you will work with simple objects of the date class. The class definition and some of the simple member functions are contained in the file F96DATECLS.CPP, which can be copied from O:\JLW\310 in Johnson, L:\JLW\310 in Tompkins or from 310LIB: on the mainframe. A date object can represent any date between 1 Jan 1800 and 31 Dec 2099. A date object consists of the day of the month (an int - from 1 to 31), month number (an int - Jan is 1 ... Dec is 12), the year number (a four-digit int), and a day number (a count of the number of days since 1 Jan 1800 - a long int). So, 13 September 1996 would be represented as day: 13, month: 9, year: 1996, and daynum: 71843.
You have two tasks for this project. First, you must write the missing four member functions and the two friend functions. The functions should work as follows.
valid
Checks a potential date value for validity. If the date would be illegal, displays an error message and returns a 0. Otherwise, return a 1. This function is used directly in one constructor and should be used indirectly in the friend operator>>.
weekday
Returns the number of the day of the week for a date. Sunday is day 0 of the week ... Saturday is day 6. For reference: 1 Jan 1800 (day number 0) was a Wednesday; weekday should return 3 for it.
operator+
Adds the rhs, a number of days (an int), to the lhs, a date, and returns the resulting date. The increment must be positive - you should check to be sure it is.
operator<
Compares two dates and returns a value indicating whether the left date is less than the right date. A return of 0 indicates false; non-zero is true.
operator>>
This friend function should be used to input a value into a date object. An input date consists of three int numbers: day of the month, month of the year, and year (in that order).
operator<<
This friend function displays the value of a date object. The display must appear as dd mmm yyyy
where dd is the day of the month, mmm is the month name abbreviation (such as Jan, Feb, etc.), and yyyy is the four-digit year.
Second, you must write a main function that does the following manipulation tasks with date objects. Each of these tasks requires use the various member functions of a date object.
1. Prompt for and read in the current date (today). Then, display a message that shows the day of the week that today is (the name of the day, not the number) and the number of days from the start of the year that today is. For example, if the input is 13 9 1996 the output should be something like:
Today is a Friday, day 257 of 1996.January 1 is regarded as day 1 of 1996.
2. Prompt for and read in the names of five people (first names only) and their birthdays. The input names and birthdays may be entered in any order.
a) As the information is entered, the program should respond to an invalid date by re-prompting and re-reading until a valid date is entered.
b) Arrange the five names and birthdays in one or two arrays and in order (oldest to youngest).
c) For each person, display the following information: name, birthday, day of the week the person was born on, the person's current age (as of today) measured in days, and the date on which each person will reach the age of 25000 days. Make sure this display lists the people in order from oldest to youngest and properly labels the values.
Hand in a printout of your program and a diskette with your source program on it.