okay I came up with something a little more complex, but it's still not working. I know it's somewhere within my functions (either the bools or whatnot)......basically it's not telling them they entered an invalid date.
Any help?? I didn't put it in there, because I can't figure out where it goes logically.
/
************************Includes**************************************/
# include<iostream>
# include<iomanip>
using namespace std;
/************************Function call*********************************/
int isLeapYear(int year); //function
int dateIsValid (int day, int month, int year); //function
/***********************Main******************************************/
int main()
{
int value1, value2, value3;
char again;
do
{
cout << "Enter the day, month, and year. \n";
cin >> value1 >> value2 >> value3;
dateIsValid(value1, value2, value3); //call function
cout << value1<<" "<< value2 <<" "<< value3<<endl;
cout << " Do you want to enter another date? (Y/N)";
cin >>again;
}while (again =='Y' || again =='y');
return 0;
}
/*************************FUNCTION*********************************/
int dateIsValid(int day, int month, int year)
{
bool valid;
int monthLength[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if ( isLeapYear(year) )
monthLength[2] = 29; // 29 days in February in a leap year
if ( month < 1 || month > 12 )
valid = false;
else if ( day < 1 || day > monthLength[month] )
valid = false;
return ( valid );
}
/****************************FUNCTION*******************************************/
int isLeapYear(int year)
{
bool result;
if ( (year%4) != 0 ) // or: if ( year%4 )
result = false; // means: if year is not …