Hello
I'm in a begginer C++ programming class. I don't understand stand my teacher. I'm looking for some help with this program. Its suppose to check if the date is valid, if the date is valid it should output the, if not then it shoud automatically loop back to the begginning of the program. My problem is that even when the date is valid it still outputs a not valid statement and it wont go into the next part of the program that ask does the user do they want to enter another date! I just need some help!
#include <iostream>
using namespace std;
int main()
{
// Variables
int month, day, year; // the date user input
char answer, NV;
// greeting
cout << "This program will find out the day of week of any " << endl
<< "date (later than January 1, 1860) you entered. \n\n";
do
{
// menu and user input
cout << "Please enter a date (mm dd yyyy): " << endl;
cout << "Month (1 - 12): ";
cin >> month;
cout << "Day (1 - 31): ";
cin >> day;
cout << "Year (1860 - ): ";
cin >> year;
if ( (month==1 || month ==3 || month == 5 || month == 7 || month== 8 || month== 10 || month==12)
&& (day >= 1 || day<=31)
&& (year>=1860 ) )
{
cout << endl << endl << "You entered "
<< month << "/" << day << "/" << year << ".\n\n" ;
}
if ( (month==4 || month ==6 || month == 9 || month == 11)
&& (day >= 1 || day<=30)
&& (year>=1860 ) )
{
cout << endl << endl << "You entered "
<< month << "/" << day << "/" << year << ".\n\n" ;
}
if((month==2) && (day>=1 || day<=28 || 29) && (year>=1860) &&
((year)>0) && !((year)%4) &&
( ((year)%100) || !((year)%400) ) )
{
// Echo user input
cout << endl << endl << "You entered "
<< month << "/" << day << "/" << year << ".\n\n" ;
}
else;
{
cout<< "Date is not valid,enter another date."<< endl;
}
}while(NV);
// Repeat?
cout << "Do you want to try another date? (Y/N): ";
cin >> answer;
while (answer == 'Y' || answer == 'y');
// Bye-bye message
cout << "Thanks for using the program. Bye-bye." << endl << endl;
return 0;