Nothing will output with my coding!!

After the user inputs the date, month, and year, nothing will output. Can someone help please?

#include <iostream>
#include <cmath>
using namespace std;

int date;
int month;
int year;
int getCenturyValue;
int getYearValue;
int getMonthValue;
int DayoftheWeek;
bool isLeapYear;

int main()
{
cout<<"Please enter the date in the form of: DD"<<endl;
cin>>date;
cout<<"Please enter the month as a number"<<endl;
cin>>month;
cout<<"Please enter the year in the form of YYYY"<<endl;
cin>>year;

if (year%400 == 0) isLeapYear = true;
else (year%400 != 0); isLeapYear = false;

if (month == 1)
{
if (bool isLeapYear = true)
{
month = 6;
}
else (isLeapYear = false);
{
month = 0;
}
}
else if (month == 2)
{
if (bool isLeapYear = true)
{
month = 2;
}
else (isLeapYear = false);
{
month = 3;
}
}
else if (month == 3)
{
month = 3;
}
else if (month == 4)
{
month = 6;
}
else if (month == 5)
{
month = 1;
}
else if (month == 6)
{
month = 4;
}
else if (month == 7)
{
month = 6;
}
else if (month == 8)
{
month = 2;
}
else if (month == 9)
{
month = 5;
}
else if (month == 10)
{
month = 0;
}
else if (month == 11)
{
month = 3;
}
else (month == 12);
{
month = 5;
}

getCenturyValue = (3-((year/100)%4))*2;
cin>>getCenturyValue;

getYearValue = (year-((year/100)*100))/4+(year-((year/100)*100));
cin>>getYearValue;

DayoftheWeek = (date+month+getYearValue+getCenturyValue)%7;
cin>>DayoftheWeek;

if (DayoftheWeek == 0)
{
cout<<"The day of the week was a Sunday!"<<endl;

system("Pause");
return 0;
}
else if (DayoftheWeek == 1)
{
cout<<"The day of the week was a Monday!"<<endl;

system("Pause");
return 0;
}
else if (DayoftheWeek == 2)
{
cout<<"The day of the week was a Tuesday!"<<endl;

system("Pause");
return 0;
}
else if (DayoftheWeek == 3)
{
cout<<"The day of the week was a Wednesday!"<<endl;

system("Pause");
return 0;
}
else if (DayoftheWeek == 4)
{
cout<<"The day of the week was a Thursday!"<<endl;

system("Pause");
return 0;
}
else if (DayoftheWeek == 5)
{
cout<<"The day of the week was a Friday!"<<endl;

system("Pause");
return 0;
}
else (DayoftheWeek == 0);
{
cout<<"The day of the week was a Saturday!"<<endl;

system("Pause");
return 0;
}

system("Pause");
return 0;
}
You are asking for input from user again
1
2
3
4
5
cin>>getCenturyValue;

cin>>getYearValue;

cin>>DayoftheWeek;

That's why your program will not display any output after user inputs the date, month, and year
and why are you taking these values from user when you have calculated them in your program.

There are so many errors other than that in your program.
1
2
f (year%400 == 0) isLeapYear = true;
else (year%400 != 0); isLeapYear = false;



isLeapYear will always be false;

same with

1
2
3
4
else (month == 12);
{
month = 5;
}



month will always be 5;


From better code writing point of view, you should use switch in place of so many nested if-else
and you can also try to handle wrong user inputs in such a program

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
#include <iostream>
//#include <cmath>
using namespace std;

int main()
{
	int nDate=0, nMonth=0, nYear=0;
	do
	{
		cout<<"Please enter the date in the form of: DD"<<endl;
		cin>>nDate;
	}
	while((nDate < 1) || (nDate > 31));
	do
	{
		cout<<"Please enter the month as a number"<<endl;
		cin>>nMonth;
	}
	while((nMonth < 1) || (nMonth > 12));
	cout<<"Please enter the year in the form of YYYY"<<endl;
	cin>>nYear;

	bool bIsLeapYear = !(nYear%400) || (!(nYear%4) && (nYear%100));
	nYear--;
	nYear %= 400;
	int DayoftheWeek = 0;
	switch(nYear/100)
	{
	case 1:
		DayoftheWeek += 5;
		break;
	case 2:
		DayoftheWeek += 3;
		break;
	case 3:
		DayoftheWeek += 1;
		break;
	}
	nYear %= 100;
	DayoftheWeek += nYear + (nYear/4);
	switch(nMonth)
	{
	case 2:
		if(nDate >= 29+bIsLeapYear)
		{
			cout<<"February month has no <<DayoftheWeek<<th day"<<endl;
			return 1;
		}
		DayoftheWeek +=3;
		break;
	case 3:
		DayoftheWeek +=3;
		break;
	case 4:
		if(nDate == 31)
		{
			cout<<"April month has no 31st day"<<endl;
			return 1;
		}
		DayoftheWeek +=6;
		break;
	case 5:
		DayoftheWeek +=1;
		break;
	case 6:
		if(nDate == 31)
		{
			cout<<"June month has no 31st day"<<endl;
			return 1;
		}
		DayoftheWeek +=4;
		break;
	case 7:
		DayoftheWeek +=6;
		break;
	case 8:
		DayoftheWeek +=2;
		break;
	case 9:
		if(nDate == 31)
		{
			cout<<"September month has no 31st day"<<endl;
			return 1;
		}
		DayoftheWeek +=5;
		break;
	case 10:
		break;
	case 11:
		if(nDate == 31)
		{
			cout<<"November month has no 31st day"<<endl;
			return 1;
		}
		DayoftheWeek +=3;
		break;
	case 12:
		DayoftheWeek +=5;
		break;
	}
	if(nMonth > 2)
		DayoftheWeek += bIsLeapYear;
	DayoftheWeek += nDate;
	DayoftheWeek %= 7;

	cout<<"The day of the week was a ";
	switch(DayoftheWeek)
	{
	case 0:
		cout<<"sunday";
			break;
	case 1:
		cout<<"monday";
			break;
	case 2:
		cout<<"tuesday";
			break;
	case 3:
		cout<<"wednesday";
			break;
	case 4:
		cout<<"thursday";
			break;
	case 5:
		cout<<"friday";
			break;
	case 6:
		cout<<"saturday";
			break;
	default:
		cout<<"unknown";
			break;
	}
	cout<<endl;

	return 0;
} 


Topic archived. No new replies allowed.