Why in the world will this not detect which year is entered and choose to output the right statement for the right year. No matter what I enter, it chooses the first if statement
if (year >= 1582 || year <=2013)
{
cout << "\n The date " << month << "/" << day << "/" << year
<< " was a ";
}
elseif (year == 2014)
{
cout << "\n The date " << month << "/" << day << "/" << year
<< " is a ";
}
elseif (year > 2014)
{
cout << "\n The date " << month << "/" << day << "/" << year
<< " will be a ";
}
switch(day_of_week)
{
case SUNDAY: cout << "Sunday."; break;
case MONDAY: cout << "Monday."; break;
case TUESDAY: cout << "Tuesday."; break;
case WEDNESDAY: cout << "Wednesday."; break;
case THURSDAY: cout << "Thursday."; break;
case FRIDAY: cout << "Friday."; break;
case SATURDAY: cout << "Saturday."; break;
}
I think you want && in line 1 instead of ||. && means "and" and || means "or". The reason the condition is always true is because every number is either greater than 1582 or less than 2013 - some numbers are both.