Question: Is anybody able to help make a flowchart for this c++ code? #include #include using namespace std; class Date { private: int month, day, year;

Is anybody able to help make a flowchart for this c++ code?

#include

#include

using namespace std;

class Date

{

private:

int month, day, year;

string monthName[12];

public:

//Function prototype for constructors

Date();

Date(int m, int d, int y);

//Function prototype for setter functions

void setMonthNames();

void setMonth(int m);

void setDay(int d);

void setYear(int y);

//Function prototype for getter functions

int getMonth();

int getDay();

int getYear();

//Function prototype for print functions

void printDateFormat1();

void printDateFormat2();

void printDateFormat3();

};

//Default constructor function definition

Date::Date()

{ setMonthNames(); }

//Parameterized constructor function definition

Date::Date(int m, int d, int y)

{

setMonth(m);

setDay(d);

setYear(y);

setMonthNames();

}

// Function definition to store month in words into array

void Date::setMonthNames()

{

monthName[0] = "January";

monthName[1] = "Feburary";

monthName[2] = "March";

monthName[3] = "April";

monthName[4] = "May";

monthName[5] = "June";

monthName[6] = "July";

monthName[7] = "August";

monthName[8] = "September";

monthName[9] = "October";

monthName[10] = "November";

monthName[11] = "December";

}

//setter functions definition

void Date::setMonth(int m)

{

if (m >= 1 || m <= 12)

month = m;

else

{

cout << "Invalid! Please enter the value of a month 1-12. ";

exit(0);

}

}

void Date::setDay(int d)

{

if (d >= 1 || d <= 31)

day = d;

else

{

cout << "Invalid value for the Day ";

exit(0);

}

}

void Date::setYear(int y)

{

year = y;

}

//getter functions definition

int Date::getMonth()

{

return month;

}

int Date::getDay()

{

return day;

}

int Date::getYear()

{

return year;

}

//function definition in mm/dd/yy format

void Date::printDateFormat1()

{

cout << getMonth() << "/" << getDay() << "/" << getYear() << endl;

}

//function definition in "monthName dd, yy" format

void Date::printDateFormat2()

{

cout << monthName[getMonth() - 1] << " " << getDay() << ", " << getYear() << endl;

}

//function definition in "dd monthName yy" format

void Date::printDateFormat3()

{

cout << getDay() << " " << monthName[getMonth() - 1] << " " << getYear() << endl;

}

int main()

{

Date dateFormat;

int mm, dd, yy;

//Taking input integer month

cout << "Enter month (1-12):";

cin >> mm;

dateFormat.setMonth(mm);

//Taking input integer day

cout << "Enter the day (1-31):";

cin >> dd;

dateFormat.setDay(dd);

//Taking input integer year

cout << "Enter the year:";

cin >> yy;

dateFormat.setYear(yy);

//Priting output in different format

cout << "Here are three possible formats you could write this date in: ";

cout << "DateFormat1: "; dateFormat.printDateFormat1();

cout << "Date Format2: ";

dateFormat.printDateFormat2();

cout << "Date Format3: ";

dateFormat.printDateFormat3();

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!