Answer to Question #274610 in C++ for Amit

Question #274610

Create a Date class with three integer instance variables named day,month,year. 

It has a constructor with three parameters for initializing the instance variables,and it has one method named daysSinceJan1(). It computes and returns the number of days since January 1 of the same year,including January 1 and the day in the Date object.

For example,if day is a Date object with day=1,month=3,and year=2000,then the calldate.daysSinceJan1() should return 61 since there are 61 days between the dates of January 1,2000,and March 1,2000,including January 1 and March 1. Don’t forget to consider leap years.

1
Expert's answer
2021-12-02T14:15:56-0500
#include <iostream>
#include <string>
using namespace std;


class Date
{
private:
    int month, day, year;
public:
    Date();
    Date(int month, int day, int year) {
        this->day = day;
        this->month = month;
        this->year = year;
    }
    ~Date(){}
    void setDay(int day){
        this->day = day;
    }
    void setMonth(int month){
        this->month = month;
    }
    void setYear(int){
        this->year = year;
    }
};

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment