Question: Help answering a few c++ questions regarding my code? #include #include #include using namespace std; //Class Month definition class Month { //Data member to store

Help answering a few c++ questions regarding my code?

#include #include #include using namespace std; //Class Month definition class Month { //Data member to store month number int monthNumber; public: //Member functions void set_month(int); int get_month(); void input(); void output(); void advance(); void before(); void after(); void same(); };//End of class //Function to check month is same or not void Month::same() { //To store month number int mo; //Variable month - to store month in character form. //Variable monthPart - to store month first three letters string month, monthPart; //Accept the month cout>month; //Checks whether the first character is number or not if(isdigit(month[0])) { //Checks whether double digit if(month.length()== 2) { //Converts to integer mo = month[0] - '0'; //Multiply by 10 and adds the next digit to make it double digit mo = mo * 10; int next = month[1] - '0'; mo = mo + next; }//End of inner if //If single digit else //Converts to integer mo = month[0] - '0'; //Checks for invalid entry if(mo 12) cout>month; //Checks whether the first character is number or not if(isdigit(month[0])) { //Checks whether double digit if(month.length()== 2) { //Converts to integer mo = month[0] - '0'; //Multiply by 10 and adds the next digit to make it double digit mo = mo * 10; int next = month[1] - '0'; mo = mo + next; }//End of inner if //If single digit else //Converts to integer mo = month[0] - '0'; //Checks for invalid entry if(mo 12) cout 12) { monthNumber = 1; }//End of if //Display the month name output(); }//End of function //Function to display the previous month void Month::before() { //Subtracts one to month number monthNumber--; //Checks if it is zero then set it to 12 for December if(monthNumber == 0) { monthNumber = 12; }//End of if //Displays the output output(); }//End of function //Function to advance the month by inputed number void Month::advance() { int no, diff; //Accept the advance number cout>no; //Adds the advance month number to month number monthNumber = no + monthNumber; //If it exceeds 12 then subtract it from 12 and store it in month number if(monthNumber > 12) { monthNumber = monthNumber - 12; }//End of if //Displays the output output(); }//End of function //Function to display the month name void Month::output() { //Month number is passed in switch to match the case switch(monthNumber) { case 1: cout>ch; //Returns user choice return ch; }//End of function //Main function definition int main() { //Month class object created Month m; //Accepts the user month number or name m.input(); //To store user choice returned by the menu function int ch; //Loops till user choice is 5 do { //Accept user choice ch = menu(); //Calls user function based on user choice switch(ch) { case 1: m.advance(); break; case 2: m.before(); break; case 3: m.after(); break; case 4: m.same(); break; case 5: exit(0); default: cout

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!