Get Day from Week Program -- DIRE NEED

I need help with my program. My program is supposed to get ask the user a date (MM DD YYYY) and its supposed to tell them what day of the week that specific date is. Well, I was told to check for leap years, and if the Feb 29 is a non-leap year, its supposed to cout an invalid statement and tells the user to try again. My problem is that its not looping through only when its Feb 29 2015 for example. Can someone help me fix this. I have been trying to find a solution and I cant find one so far? Like, I said, it works for other dates, just not checking and looping Feb 29 2014 or 2015, etc?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#include <iostream> 

using namespace std; 
  
const int JANUARY   = 1; 
const int FEBRUARY  = 2; 
const int MARCH     = 3; 
const int APRIL     = 4; 
const int MAY       = 5; 
const int JUNE      = 6; 
const int JULY      = 7; 
const int AUGUST    = 8; 
const int SEPTEMBER = 9; 
const int OCTOBER   = 10; 
const int NOVEMBER  = 11; 
const int DECEMBER  = 12; 

// Returns true if the given year is a leap year
bool is_leap_year(int year); 
// Returns a value computed from the century of the year
int get_century_value(int year); 
// Returns a value computed based on the years since the beginning of the century.
int get_year_value(int year);
// Returns a value (from a table) for the given month  
int get_month_value(int month, int year);  

int main() 

{  
 
int month =0;
int day = 0; 
int year = 0;
int day_of_week = 0; 
int days_in_month = 0;
bool dates_invalid=true;

do
{

cout << endl;	
cout << " Please enter a integer (between 1 and 12) corresponding " << endl;
cout << endl;
cout << " to the appropriate month (January to December): "; 
cin >> month; 
cout << endl;

cout << endl;
cout << " Please enter a integer (between 1 and 31) corresponding" << endl;
cout << endl;
cout << " to the number of days in that particular month: "; 
cin >> day;
cout << endl;
cout << endl;
cout << " Please enter a year (between 2000 and 2020): ";
cin >> year;
cout << endl;
cout << endl;


//check for leap year
if(month == 9 || month == 4 || month == 6  || month == 11)
	{
		days_in_month = 30;

	}
	else if(month == 2)
	{ 
		if( (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
		{
			days_in_month = 29;
		}
		else
		{
			days_in_month = 28;
		}
	}
	else
	{
		days_in_month = 31;
	}


	if( month < 1 || month > 12 || day <= 0 || day > days_in_month)
	{
		cout << endl;
		cout << " You have entered an invalid date. Please try again." << endl;
		dates_invalid=false;
		cout << endl;
		cout << endl;
	
	}

if( year < 2000 || year > 2020)
	{
		cout << endl;
		cout << " You have entered an invalid date. Please try again." << endl;
		dates_invalid=false;
		cout << endl;
		cout << endl;
	
	}
else 

	dates_invalid = true;

}
while (dates_invalid==false);


// Compute the day of the week
day_of_week = day + get_month_value(month, year) + get_year_value(year) + get_century_value(year);    
    
day_of_week = day_of_week % 7; 

cout << endl;
cout << endl; 
cout << "\n The date " << month << "/" << day << "/" << year 
     << " is a ";  

    if (day_of_week == 0) 
    { 
		cout << "Sunday."; 
    }  
    else if (day_of_week == 1) 
    { 
		cout << "Monday."; 
    }  
    else if (day_of_week == 2) 
    { 
		cout << "Tuesday."; 
    }  
    else if (day_of_week == 3) 
    { 
		cout << "Wednesday."; 
    }  
    else if (day_of_week == 4) 
    { 
		cout << "Thursday."; 
    }  
    else if (day_of_week == 5) 
    { 
		cout << "Friday."; 
    }  
    else if (day_of_week == 6) 
    { 
		cout << "Saturday."; 
    }  
    cout << endl;
    cout << endl;
    return 0; 
}

// Prompts the user to input a month, day and year 
void get_input(int month, int day, int year) 

{  
	cout << endl;
	cout << " Please enter a month: "; 
    cin >> month; 
    cout << endl;
    cout << " Please enter a day: "; 
    cin >> day;
    cout << endl;
    cout << " Please enter a year: "; 
	cout << endl;
    cin >> year;
}

// Returns true if the given year is a leap year 

bool is_leap_year(int year) 

{  
    return (((year % 400) == 0) ||(((year % 4) == 0) 
	&& ((year % 100) != 0))); 

} 
Wouldn't it make more sense just to loop it over to March 1st if it isn't a leap year? Or for any access to a day that is longer than the month- just go up to the next one.

Also, line 69's if statement should just use is_leap_year for brevity.
Er, there's actually a pretty simple formula to get the day of the week
http://www.tondering.dk/claus/cal/chrweek.php#calcdow
Topic archived. No new replies allowed.