Write a class datetype it can perform the following operations on a date , in addition to the operation already defined :
1-set the month
2-set the day
3-set the year
4-return the month
5-return the day
6-return the year
7-test the year is a leap year
8-return the number of days in the month for example if the date is 3-18-2006 the number of days to be returned is 31 because there is 31 days in march
9-return the number of days passed in the year for example if the date is 3-18-2006 the number of days passed in the year is 77.note that the number of days returned also includes the current days.
10-return the number of days remaining in the year for example if the date is 3-18-2006 the number of days remaining in the year is 288.
11-calculate the new date by adding a fixed number of days to the date for example if the date is 3-18-2006 and the days to be added are 25 the new date is 4-12-2006.

2
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by einas

but can i get solve or not
please i need it toooo much

Absolutely not. You need to put forth a good-faith effort first. Then you will get guidance on how to correct it. I suggest you read the link I gave you again, since you obviously either didn't read it, or you chose to ignore the information contained within it.

Edited by Fbody: n/a

ok thanks
i fail in 2 exams in this subject
oh no
thank you again

``````#include<iostream.h>
#include<conio.h>

class date
{
private:
int year;
int month;
int day;

public:
date(int year1, int month1, int day1)
{
year=year1;
month=month1;
day=day1;
}
long Day();
long operator-(long);
};

long date:: Day()
{
long p;
long a[13],i,t=0;

char* b[7];
a[1]=a[3]=a[5]=a[7]=a[8]=a[10]=a[12]=31;
a[4]=a[6]=a[9]=a[11]=30;
a[2]=28;
for(i=1;i<year;i++)
if(i%400==0||(i%4==0&&i%100!=0))
t++;
p=(year-1)*365+t;
if(year%400==0||(year%4==0&&year%100!=0))
a[2]=29;
for(i=1;i<month;i++)
p+=a[i];
p+=day;
return p;
}

long date::operator-(long d1)
{
int d2;
d2=d2-d1.Day();
return d2;
}

main()
{
date d3,
d1(2006,3,18),
d2(2006,3,18);
d3=d2-d1;
}``````

this is my answer
is it right