Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#include <string> using namespace std; class daytype { private : string weekday;

ID: 3533665 • Letter: #

Question

#include <string>

using namespace std;

class daytype

{

private:

       string weekday;

public:

       void setday(string d);

daytype();

daytype(string d);

};

#include<iostream>

#include<string>

#include "daytype.h"

using namespace std;

void daytype::setday(string d)

{

       weekday=d;

}

daytype::daytype()

{

weekday = "sunday";

}

daytype::daytype(string d)

{

       weekday = d;

}

#include<iostream>

#include<string>

#include "daytype.h"

using namespace std;

int main()

{

daytype myday;

daytype yourday("Monday");

myday.setday("Friday");

       return 0 ;

}


Q. In this chapter, the class dateType was designed to implement the date in a program, but the member function setDate and the constructor do not check whether the date is valid before storing the date in the member variables. Rewrite the definitions of the function setDate and the constructor so that the values for the month, day, and year are checked before storing the date into the member variables. Add a member function, isLeapYear, to check whether a year is a leap year. Moreover, write a test program to test your class.


NOTE: PLEASE MODIFY THE ABOVE PROGRAM ACCORDING TO THE QUESTION. thank you

Explanation / Answer

class dateType { //THE CONSTRUCTOR public: dateType(); dateType(int newMonth, int newDay, int newYear); // get methods int getYear() const; int getMonth() const; int getDay() const; private: int year; int month; int day; };