Question: Please use C++ for this problem. Please refer to the samples as how the output should look. Define a class called Month that is an
Please use C++ for this problem. Please refer to the samples as how the output should look.
Define a class called Month that is an abstract data type for a month. Your class should have a private integer variable that represents the month (1 for January, 2 for February, etc.). Include all the following member functions: - A default constructor that set's the month to January. - A constructor to set the month using the first three letters in the name of the month as three arguments. - A constructor to set the month using an integer as an argument. - A mutator function that sets the month by passing in an integer. - An accessor function that returns the value of the month as an integer. - An accessor function that returns the first three letters in the name of the month. - A Member function that returns the next month as a value of type Month. Make sure your class validates user input to verify that a valid month was entered. In main(), test your program by creating 3 different Month objects. The first month object should use an integer value entered by the user as the argument to the constructor. Then, use the Month class member functions to print out the first three letters of the corresponding month and the first three letters of the next month. The second month object should take 3 letters that the user enters as arguments to the constructor. Then, use the Month class member functions to print out the value of that month as an integer, as well as the first three letters of the next month. The third month object should be created using the default constructor. Print out the first three letters of that month and the next month.
Sample 1: Enteramonthvalueasaninteger:12 ThismonthisDEC. ThenextmonthisJAN. Enterthefirstletterofthemonthname:S Enterthesecondletterofthemonthname:E Enterthethirdletterofthemonthname:P Thisismonthnumber9. ThenextmonthisOCT. Usingthedefaultconstructor,themonthisJAN. ThenextmonthisFEB.
Sample 2: Enteramonthvalueasaninteger:17 Enteravaluebetween1and12:7 ThismonthisJUL. ThenextmonthisAUG. Enterthefirstletterofthemonthname:a Enterthesecondletterofthemonthname:p Enterthethirdletterofthemonthname:r Thisismonthnumber4. ThenextmonthisMAY. Usingthedefaultconstructor,themonthisJAN. ThenextmonthisFEB.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
