Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Add the following operations to the class dateType, 1) set the month 2) set the day 3) set the year 4) return the month

C++

Add the following operations to the class dateType,

1) set the month

2) set the day

3) set the year

4) return the month

5) return the year

6) test whether the year is a leap year

7) return the number of days in the month

8) return the days passed in the year.

For example, if the date is 3-18-2011, the number of days passed is 77.

Note that the number of days returned also includes the current day.

9) return the number of days remaining in the year. For example, if the

date is 3-18-2011, the number of days remaining in the year is 288.

date.h

#pragma once //************************************************************ // Author: D.S. Malik // // class dateType // This class specifies the members to implement a date. //************************************************************

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.

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 };

date.cpp

//Implementation file date

#include #include "date.h"

using namespace std; void dateType::setDate(int month, int day, int year) { dMonth = month; dDay = day; dYear = year; }

int dateType::getDay() const { return dDay; }

int dateType::getMonth() const { return dMonth; }

int dateType::getYear() const { return dYear; }

void dateType::printDate() const { cout << dMonth << "-" << dDay << "-" << dYear; }

//Constructor with parameters dateType::dateType(int month, int day, int year) { setDate(month, day, year); }

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

More Books

Students also viewed these Databases questions