LESSON 30 LAB EXERCISE DAYSAPART

Assignment:

1.   After you have completed and thoroughly tested the date class, write a different client program to solve another date-related problem.  This program will use the date abstraction to solve a daysApart function.  The specifications and function prototype of this function are given below.

      int  daysApart (date day1, date day2);

      //  if day1 = day2, then the function returns 0, otherwise the function returns the number of

      //  days which separates the two dates.  For example:

      //    6/27/96  and  6/28/96 are 1 day apart

      //    11/2/60  and  10/27/60 are 6 days apart

      //    2/27/96  and  3/10/96 are 12 days apart (leap year issue)

2.   Run your program on these test inputs:

6/27/96 and 6/27/96

6/27/96 and 6/28/96

6/28/96 and 6/27/96

1/1/95 and 1/1/96

1/1/96 and 1/1/95

 

2/25/96 and 3/10/96

3/10/96 and 2/25/96

12/25/96 and 1/6/97

1/6/97 and 12/25/96

3.   Turn in only the code for the client program which includes the  daysApart  function.  Include the run output for the above test values.  Your run output should be formatted something like this:

      6/27/96 and 6/27/96  are  0  days apart

      6/27/96 and 6/28/96  are  1  days apart      (printing 1 day is optional)

      1/1/95 and 1/1/96  are  365  days apart

      etc.