Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help me this question in C++: Dina\'s Date class has a function called mo

ID: 3809414 • Letter: P

Question

Please help me this question in C++:

Dina's Date class has a function called monthDays that has a month number parameter and returns the number of days in the month passed in. Here is the function definition:

int Date :: monthDays (int month)

{

... // actual code not needed

}

Alex creates a Date object called date1 using an appropriate constructor. Show the statement that Alex must write to call the monthDays function with the month number 6 and store the results in an appropriate variable.

Thank you so much.

Explanation / Answer

#include <iostream>
using namespace std;

class Date{
public:
int monthDays(int monthNum);
};

int Date::monthDays(int n){
if(n==1||n==3||n==5||n==7||n==8||n==10||n==12)
return 31;

if(n==4||n==6||n==9||n==11)
return 30;

if(n==2)
return 28;
}
int main() {
   // your code goes here
   Date date1;
  
   int days=date1.monthDays(6);
  
   return 0;
}