// This is the sample solution for SYSC 2002 lab #1 version #1 (D1) #include "stdstuff.h" #include "Date.h" int main () { Date todayDate, readDate, sentinelDate(1,1,2099); int days; // prompt for, read in, and output today's date cout << "Enter today's date (DD MM YYYY): "; todayDate.read(cin); cout << "Today's date is: "; todayDate.write(cout); cout << "\n\n"; // or use endl for (;;) { // prompt for and read in another date (use 1 1 2099 to quit) cout << "Enter another date (DD MM YYYY; 1 1 2099 to quit): "; readDate.read(cin); // break if sentinel date entered if (readDate.compareTo(sentinelDate)==0) break; // otherwise output the date cout << "You entered: "; readDate.write(cout); cout << "\n"; // find difference days = readDate.daysAfter(todayDate); cout << "That date is " << days << " days after today.\n"; // check if same day in week (could also check if days is a multiple of 7) if (todayDate.dayInWeek()==readDate.dayInWeek()) cout << "That date is the same day of the week as today.\n"; else cout << "That date is not the same day of the week as today.\n"; // find date the same number of days before today // (could use todayDate and move by -days, but would need to make a copy) readDate.move(-days*2); cout << "The date " << days << " days before today is: "; readDate.write(cout); cout << ".\n\n"; } pause(); return 0; }