Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given dataType.h #ifndef date_H #define date_H class dateType { public: void setDate(int month, int day, int year); //Function to set the date. //The member variables

image text in transcribed

Given

dataType.h

#ifndef date_H

#define date_H

class dateType

{

public:

void setDate(int month, int day, int year);

//Function to set the date.

//The member variables dMonth, dDay, and dYear are set

//according to the parameters

//Postcondition: dMonth = month; dDay = day;

// dYear = year

int getDay() const;

//Function to return the day.

//Postcondition: The value of dDay is returned.

int getMonth() const;

//Function to return the month.

//Postcondition: The value of dMonth is returned.

int getYear() const;

//Function to return the year.

//Postcondition: The value of dYear is returned.

void printDate() const;

//Function to output the date in the form mm-dd-yyyy.

bool isLeapYear();

//Function to determine whether the year is a leap year.

dateType(int month = 1, int day = 1, int year = 1900);

//Constructor to set the date

//The member variables dMonth, dDay, and dYear are set

//according to the parameters

//Postcondition: dMonth = month; dDay = day;

// dYear = year

//If no values are specified, the default values are

//used to initialize the member variables.

private:

int dMonth; //variable to store the month

int dDay; //variable to store the day

int dYear; //variable to store the year

};

#endif

dateTypeImp.cpp

//Implementation file date

#include

#include "dateType.h"

using namespace std;

void dateType::setDate(int month, int day, int year)

{

cout

if (year >= 1)

dYear = year;

else

{

cout

dYear = 1900;

}

if (1

dMonth = month;

else

{

cout

dMonth = 1;

}

switch (dMonth)

{

case 1:

case 3:

case 5:

case 7:

case 8:

case 10:

case 12:

if (1

dDay = day;

else

{

cout

dDay = 1;

}

break;

case 4:

case 6:

case 9:

case 11:

if (1

dDay = day;

else

{

cout

dDay = 1;

}

break;

case 2:

if (isLeapYear())

{

cout

if (1

dDay = day;

else

{

cout

dDay = 1;

}

}

else

{

if (1

dDay = day;

else

{

cout

dDay = 1;

}

}

}

}

int dateType::getDay() const

{

return dDay;

}

int dateType::getMonth() const

{

return dMonth;

}

int dateType::getYear() const

{

return dYear;

}

bool dateType::isLeapYear()

{

if (((dYear % 4 == 0) && (dYear % 100 != 0)) || dYear % 400 == 0)

return true;

else

return false;

}

void dateType::printDate() const

{

cout

}

//constructor

dateType::dateType(int month, int day, int year)

{

setDate(month, day, year);

}

IC3_DateDriver.cpp

#include

//#include

#include "dateType.h"

using namespace std;

int main()

{

system ("pause");

return 0;

}

You must modify the main function to call the class functions.. (10 points) Make sure that your calls and/or constructors test examples of leap year, 31 day months, 30 day months, and entry of invalid month/day/ycar and that it prints appropriate output. (10 points) You must use the rand fucntion to generate random data to automatically generate date information for month day and year. (10 points) You must test for erroncous date information. (10 points) You must minimally call the constructor, setDate, and printDate functions for the various scenarios. (10 points) Code must compile and execute properly. (50 points) 50 points for correct output (output varies based on main program implementation but should minimally test all functions). My sample output is given below c:Documents and Settings lowner My Documents Visual Studio 20081Projects itry Debugltr.... Date Entered:3-15-2008 Date Entered:15-20-2008 invalid month entered; month will default to 1 DateEntered:2-30-2009 invalid day enteredi day will default to 1 Date Entered:1-1-1900 Date 1: 3-15-2008 Date 2: 1-20-2008 Date 3 2-1-2009 Enter month day year: 1-2-2003 DateEntered:1--2-2003 invalid year entered; year will default to 1900 invalid day entered; day will default to 1 Date 4: 1-1-1900 Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 9th International Conference Dasfaa 2004 Jeju Island Korea March 2004 Proceedings Lncs 2973

Authors: YoonJoon Lee ,Jianzhong Li ,Kyu-Young Whang

2004th Edition

3540210474, 978-3540210474

Students also viewed these Databases questions