Question: PROBLEM DESCRIPTION: This assignment calls for you to create a makefile and a fully functional NextDate() function. IMPLEMENTATION NOTES: Do all your work in a

 

PROBLEM DESCRIPTION: This assignment calls for you to create a makefile and a fully functional NextDate() function.

IMPLEMENTATION NOTES: Do all your work in a directory ~/OLA/ola208 that you will create. Copy the files DateType.h, DateType.cpp, and DateTypeExample.cpp from $PUB. The NextDate() function in DateType.cpp is only a stub; complete it. Also modify the identification items (such as "student name", section number, etc.) in these three files. Create a makefile suitable for compiling and linking these files; you may use verbatim the makefile shown below. Use as your executable file name "DateTypeExample".

DateType.cpp

#include  #include  using namespace std; #include "DateType.h" void SetDate(DateType& date, int mo, int da, int yr) { date.month = mo; date.day = da; date.year = yr; } void PrintDate(DateType date) { cout << date.month << "/" << date.day << "/" << setfill('0') << setw(2) << date.year%100 << setfill(' ') << endl; } DateType NextDate(DateType date) { DateType newDate; int monthEnd; newDate = date; newDate.day++; // ... replace with remaining code ... return newDate; } 

Datetype.h

#ifndef DateType_h /* To prevent multiple inclusion problems */ #define DateType_h struct DateType { int month; int day; int year; }; void SetDate(DateType& date, int mo, int da, int yr); void PrintDate(DateType date); DateType NextDate(DateType date); #endif 

DateTypeExample.cpp

#include  using namespace std; #include "DateType.h" int main() { DateType today, tomorrow, valentinesDay; cout << "DateTypeExample by student name "; SetDate(today,2,13,2016); // today.month = 2; // today.day = 13; // today.year = 2016; PrintDate(today); // should print 2/13/16 tomorrow = NextDate(today); PrintDate(tomorrow); // should print 2/14/16 valentinesDay = tomorrow; PrintDate(valentinesDay); // should print 2/14/16 SetDate(today,12,31,1999); tomorrow = NextDate(today); PrintDate(tomorrow); // should print 1/1/00 SetDate(today,2,28,1900); tomorrow = NextDate(today); PrintDate(tomorrow); // should print 3/1/00 SetDate(today,2,28,2000); tomorrow = NextDate(today); PrintDate(tomorrow); // should print 2/29/00 SetDate(today,2,28,2017); tomorrow = NextDate(today); PrintDate(tomorrow); // should print 3/1/17 SetDate(today,2,28,2016); tomorrow = NextDate(today); PrintDate(tomorrow); // should print 2/29/16 return 0; } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!