Help with date validation.

Hi, Im a student and new to c++. Im using code::blocks and i can seem to get the output right. we where given a program that validates a date including the leap year and use a function Valid_Date() that takes 3 arguments (month, day, year). The year must not be less than 1900 nor greater than 2100 and includes. If date is correct is will output VALID! else NOT VALID! i need help.

Here's the code. Is it possible using only if statement?

#include <iostream>
using namespace std;

void valid_date (int month, int day, int year)
{
if (((month == 1,3,5,7,8,10 ) && (month <=12) && (day <= 31)) && ((year >= 1900) && (year <= 2100)))
{
if (((month == 4,6,9,11) && (day <= 30)) && ((year >= 1900) && (year <= 2100)))
{
if (month != 2)
{
cout << "VALID!";
}
}
else
{
cout << "NOT VALID!";
}
}
else
{
cout <<"NOT VALID!";
}

if (((year % 4 == 0) && ((month = 2) && (day < 30)) && ((year >= 1900) && (year <= 2100))))
{
cout <<"VALID!";
}
else
{
cout <<"NOT";
}

if (((year % 4 != 0) && (month == 2) && (day < 29)) && ((year >= 1900) && (year <= 2100)))
{
cout <<"VALID!";
}
else
{
cout<<"NOT!";
}
}


int main ()
{
int month, day, year;

cout << "Month: ";
cin >> month;
cout << "Day: ";
cin >> day;
cout << "Year: ";
cin >> year;

valid_date( month, day, year );

return 0;
}
Topic archived. No new replies allowed.