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

Please code in C++. Write a class of objects named Date that remembers informati

ID: 3838745 • Letter: P

Question

Please code in C++.

Write a class of objects named Date that remembers information about a month and day. Ignore leap years and don't store the year in your object. You must include the following public members:

Write a class of objects named Date that remembers information about a month and day. Ignore leap years and don't store the year in your object. You must include the following public members: member name description Date (m, d) constructs a new date representing the given month and day daysInMonth() returns the number of days in the month stored by your date object get Day() returns the day get Month returns the month next Day advances the Date to the next day, wrapping to the next month and/or year if necessary returns a string representation such as "07/04' toString You should define the entire class including the class heading, the private member variables, and the declarations and definitions of all the public member functions and constructor.

Explanation / Answer

class Date{
   private:
       int day;
       int month;
       int daysinmonth;
   public:
     Date (int d, int m){
         day = d;
         month = m;
     }
     void setDaysInMonth(int n){
          daysinmonth = n;
     }
     int daysInMonth(){
         return daysinmonth;
     }
     int getDay(){
        return day;
     }
     int getMonth(){
        return month;
     }
     void nextDay(){
       
        if (day == daysinmonth)
           month = month % 12 + 1
        day = day % daysinmonth + 1;
     }
     string toString(){
        string str;
        if (day < 10)
           str = "0" + std::to_string(day);
        else
           str = std::to_string(day);
        str = str + "/";
        if (month < 10)
           str = str + "0" + std::to_string(month);
        else
           str = str + std::to_string(month);
        return str;
     }
}