Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++, use visual studio. I have code here but there is lots of error. #include using namespace std; // classs declaration class dateTpe { private:

C++, use visual studio. I have code here but there is lots of error.

#include using namespace std; // classs declaration class dateTpe { private: int dMonth; int dDay; int dYear; public: // memeber function declaration void setDate(int month, int day, int year); int getDay()const; int getMonth()const; int getYear()const; void printDate()const; bool isLeapYear(int year); dateType(int month=0, int day=0, int year=0); }; // member function definations void dateType::setDate(int month, int day, int year) { int noDyas; if (year <= 2008) { // condition to check wheather year is valid dYear = year; if (month <= 12) { // condition for month dMonth = month; switch (month) { // for number of days in each month case 1: case 3: case 5: case 7: case 8: case 10: case 12: noDays = 31; break; case 4: case 6: case 9: case 11: noDays = 31; break; case 2: if (isLeapYear(year)) noDays = 29; else noDays = 28; } if (day <= noDays) { // condition for dyas based on no of days in month dDay = day;

} else { cout << "Invalid Day" << endl; dDay = 0; }

} else { cout << "Invalid Month" << endl; dMonth = 0; }

} else { cout << "Invalid Year" << endl; dYear = 0;

} } bool dateType::isLeapYear(int year) { // function to confirm if (year % 4 == 0) return true; else return false;

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

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

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions

Question

3. Define the roles individuals play in a group

Answered: 1 week ago