im still kinda confused ill put it in the program ill attatch my program it needs to count how many days out of 365 is that date entered taking in part the leap year and the days of the month necessary for each month as you can see in my program i did all that.
#include
#include
#include
using namespace std;
class Date
{
public:
// Constructors
Date(); // default constructor
Date(int m, int d, int y);
// other member functions
void output_numeric();
void output_string();
int get_month();
int get_day();
int get_year();
void set_to_nextday();
void set_to_prevday();
bool is_leap();
int monthdays();
int yeardays();
private:
int DaysInSuchMonth();
void check_date();
int month;
int day;
int year;
string dayTostring(int month);
};
int main()
{
Date bday(3,10,1986);
Date bday1(3,10,1986);
Date bday2(3,10,1986);
int m, d, y;
cout <<"Enter a date on or after 1/1/1800 in the form month/day/year:";
char ch;
cin >> m >> ch >> d >> ch >> y;
Date someday(m,d,y);
Date someday1(m,d,y);
Date someday2(m,d,y);
cout< 12) || (day < 1) || (day > monthdays()) || (year < 1800))
{
cout << "Invalid date!"<< endl;
exit(1);
}
}
bool Date::is_leap()
{
if ((year%400)==0)
return true;
else if((year%4)==0)
return true;
else
return false;
}
int Date::DaysInSuchMonth()
{
switch(month)
{
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
return 31;
case 2:
if (is_leap())
return 29;
else
return 28;
default:
return 30;
}
}
int Date::monthdays()
{
return DaysInSuchMonth();
}
int Date::yeardays()
{
if (is_leap())
return 366;
else
return 365;
}
void Date::set_to_nextday()
{
if (++day>monthdays())
{
day=1;
if (++month >12)
{
month =1;
year++;
}
}
}
void Date::set_to_prevday()
{
if (--day < 1)
{
if (--month<1)
{
month = 12;
year--;
}
day=monthdays();
}
check_date();
}