Question
Previous code #include #include using namespace std; //Day of the year class declaration class DayOfYear { private: int day; static int MonthDays[]; static string MonthName[];
Previous code
#include
//Day of the year class declaration class DayOfYear { private: int day; static int MonthDays[]; static string MonthName[]; public: int getDay() { return day; } void operator++(int); DayOfYear operator--(int); DayOfYear(){} DayOfYear(int day) { this->day = day; } DayOfYear(string month,int date) { int i; for( i = 0 ; i day = (this->day%365 + 1); } DayOfYear DayOfYear::operator--(int) { if(day == 1) day = 365; else day = day - 1; return DayOfYear(day); }
void DayOfYear::print() { int month = 0;
while (MonthDays[month]
//Display month and day cout
int main() { //Set days of each month into an array char c; do{ cout> n; switch(n) { case 1 : {int day; //Ask user the total day number cout > day; DayOfYear dYear(day); //Error check for negative numbers and numbers higher than one year if(day 365) { cout >month; cout>date; DayOfYear dYear1(month,date); cout>c; }while(c== 'y' || c == 'Y'); system("pause"); return 0;
}
Section 12.7 (pages 805-810) and Section 11.2 (pages 681- 688). Run your code, submit the output and code too. Submit code in a separate, compliable file, do NOT include it in your pdf or text file IMPORTANT: Write a main function that tests your code, and provide data in your main function. Do NOT get the input from the user even if the question says so. 1. Programming challenges 11.3, Day of the Year Modification, page 768. [2 points 2. Programming challenges 11.7, Corporate Sales, page 769. [2 points] 3. Day of the Year Modification Modify the DayofYear class, written in an earlier Programming Challenge, to add a con- structor that takes two parameters: 0 through 31 representing the day of the month. The constructor should then initialize the integer member of the class to represent the day specified by the month and day of month parameters. The sage if the number entered for a day is outside the range of days for the month given. a string representing a month and an integer in the range constructor should terminate the program with an appropriate error mes- Add the following overloaded operators: ++ prefix and postfix increment operators. These operators should modify the DayofYear object so that it represents the next day. If the day is already the end of the year, the new value of the object will represent the first day of the year prefix and postfix decrement operators. These operators should modify the DayofYear object so that it represents the previous day. If the day is already the first day of the year, the new value of the object wi Il represent the last day of the yearStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started