Help to complete this birthday software?

I am creating a software in which if user gives his birthday like 12 March 2002 and this software will give day of his birth like Monday.
But I am stuck at a problem, when I enter birthday, this software skips everything and just go to at end statements Like "Do, you want to software again or not" and show nothing else why?
Here is output https://i.imgsafe.org/8ea94a9.png

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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
#include <iostream>
using namespace std;
int main()
{
	int day_date, month, year;
	char ye_1, ye_2, again;

	do
	{
		cout << "Enter your day date of birth:- ";
		cin >> day_date;
		cout << "Enter the month of your birthday:- ";
		cin >> month;
		cout << "Enter the year of your birthday:- ";
		cin >> ye_1;
		cin >> ye_2;
		cin >> year;
		cout << "     \n";

		switch (ye_1)
		{
		case 1:
			{
				int main_num;
				char leap_year;
				main_num = year / 4;
				main_num += year;
				main_num += day_date;

				cout << "Is you year is a Leap Year?\n";
				cout << "Type Y for yes and N for No\n";
				cin >> leap_year;

				switch (leap_year)
				{
				case 'Y':
				case 'y':
					{
						if (month == 1)
							main_num += 6;
						else if (month == 2)
							main_num += 2;
						else if (month == 3)
							main_num += 3;
						else if ( month == 4)
							main_num += 6;
						else if (month == 5)
							main_num += 1;
						else if (month == 6)
							main_num += 4;
						else if (month == 7)
							main_num += 6;
						else if (month == 8)
							main_num += 2;
						else if (month == 9)
							main_num += 5;
						else if (month == 10)
							main_num += 7;
						else if ( month == 11)
							main_num += 3;
						else if (month == 12)
							main_num += 5;
						else
							cout << "Wrong Input for month\n";
						do
						{
							main_num -= 7;
						} while (main_num <= 7);

						switch (main_num)
						{
						case 1:
							cout << "Your birth day is Monday\n";
							break;
						case 2:
							cout << "Your birth day is Tuesday\n";
							break;
						case 3:
							cout << "Your birth day is Wednesday\n";
							break;
						case 4:
							cout << "Your birth day is Thursday\n";
							break;
						case 5:
							cout << "Your birth day is Friday\n";
							break;
						case 6:
							cout << "Your birth day is Saturday\n";
							break;
						case 7:
							cout << "Your birth day is Sunday\n";
							break;
						default:
							cout << "Bad Result ERROR\n";
							break;
						}
					}
				case 'N':
				case 'n':
					{
						if (month == 1)
							main_num += 7;
						else if (month == 2)
							main_num += 3;
						else if (month == 3)
							main_num += 3;
						else if ( month == 4)
							main_num += 6;
						else if (month == 5)
							main_num += 1;
						else if (month == 6)
							main_num += 4;
						else if (month == 7)
							main_num += 6;
						else if (month == 8)
							main_num += 2;
						else if (month == 9)
							main_num += 5;
						else if (month == 10)
							main_num += 7;
						else if ( month == 11)
							main_num += 3;
						else if (month == 12)
							main_num += 5;
						else
							cout << "Wrong Input for month\n";
						do
						{
							main_num -= 7;
						} while (main_num <= 7);

						switch (main_num)
						{
						case 1:
							cout << "Your birth day is Monday\n";
							break;
						case 2:
							cout << "Your birth day is Tuesday\n";
							break;
						case 3:
							cout << "Your birth day is Wednesday\n";
							break;
						case 4:
							cout << "Your birth day is Thursday\n";
							break;
						case 5:
							cout << "Your birth day is Friday\n";
							break;
						case 6:
							cout << "Your birth day is Saturday\n";
							break;
						case 7:
							cout << "Your birth day is Sunday\n";
							break;
						default:
							cout << "Bad Result ERROR\n";
							break;
						} 
					} 
				}
			}
			case 2:
				{

					int main_num;
					char leap_year;
					main_num = year / 4;
					main_num += year;
					main_num += day_date;
					
					cout << "Is you year is a Leap Year?\n";
					cout << "Type Y for yes and N for No\n";
					cin >> leap_year;

					switch (leap_year)
					{
					case 'y':
					case 'Y':
						{

							if (month == 1)
								main_num += 5;
							else if (month == 2)
								main_num += 1;
							else if (month ==3)
								main_num += 2;
							else if (month == 4)
								main_num += 5;
							else if (month == 5)
								main_num += 6;
							else if (month == 6)
								main_num += 3;
							else if (month == 7)
								main_num += 5;
							else if (month == 8)
								main_num += 1;
							else if (month == 9)
								main_num +=4;
							else if (month == 10)
								main_num += 6;
							else if (month == 11)
								main_num += 2;
							else if (month == 12)
								main_num += 4;

							do
							{
								main_num -= 7;
							} while (main_num <= 7);

							switch (main_num)
							{
							case 1:
								cout << "Your birth day is Monday\n";
								break;
							case 2:
								cout << "Your birth day is Tuesday\n";
								break;
						        case 3:
							    cout << "Your birth day is Wednesday\n";
								break;
						        case 4:
								cout << "Your birth day is Thursday\n";
								break;
							case 5:
								cout << "Your birth day is Friday\n";
								break;
							case 6:
								cout << "Your birth day is Saturday\n";
								break;
							case 7:
								cout << "Your birth day is Sunday\n";
								break;
							default:
								cout << "Bad Result ERROR\n";
								break;
							}
						}
					case 'n':
					case 'N':
						{
							if (month == 1)
								main_num += 6;
							else if (month == 2)
								main_num += 2;
							else if (month ==3)
								main_num += 2;
							else if (month == 4)
								main_num += 5;
							else if (month == 5)
								main_num += 6;
							else if (month == 6)
								main_num += 3;
							else if (month == 7)
								main_num += 5;
							else if (month == 8)
								main_num += 1;
							else if (month == 9)
								main_num +=4;
							else if (month == 10)
								main_num += 6;
							else if (month == 11)
								main_num += 2;
							else if (month == 12)
								main_num += 4;

							do
							{
								main_num -= 7;
							} while (main_num <= 7);

							switch (main_num)
							{
							case 1:
								cout << "Your birth day is Monday\n";
								break;
							case 2:
								cout << "Your birth day is Tuesday\n";
								break;
						        case 3:
							    cout << "Your birth day is Wednesday\n";
								break;
						        case 4:
								cout << "Your birth day is Thursday\n";
								break;
							case 5:
								cout << "Your birth day is Friday\n";
								break;
							case 6:
								cout << "Your birth day is Saturday\n";
								break;
							case 7:
								cout << "Your birth day is Sunday\n";
								break;
							default:
								cout << "Bad Result ERROR\n";
								break;
							}
						}

					}

				}

		}

		cout << "       \n";
		cout << "Do you to use program again?\n";
		cout << "Type Y for Yes and N for No\n";
		cin >> again;
	} while ( (again == 'y') || (again == 'Y') );

	return 0;
}
Last edited on
show us your input
The problem is in your switch statement switch (ye_1)
If I enter 1965 for my year of birth ye_1 contains '1', but you don't handle it and so your program goes straight to line 307.

BTW. There is a much simpler solution for your task.
http://stackoverflow.com/questions/11972368/c-get-which-day-by-input-date
#Thomas1965 Why there is problem in switch (ye_1), because I am doing right.
User will either enter 19-- or 20-- so, ye_1 will either get 1 or 2. So we know all that we can use integers in Switch Statement.
Last edited on
But ye_1 and ye_2 are chars and they will never be equal to 1 or 2.
If you want to use char type you need to check for '1' and '2' in switch statement, not for 1 and 2.
Or just change their type to int.
Last edited on
char type can in fact be equal to 1 or 2, but in this case naaissus is right.
Is there any short mehod available than above one to solve this problem in correct way???
Topic archived. No new replies allowed.