Date Validator

#include <iostream>
#include <iomanip>
#include <conio.h>

using namespace std;

void getDate(int& , int& , int& );
int ckDate (int, int, int);
void displayMsg (int);

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

while(cin)
{
getDate(month, day, year);
ckDate (month, day, year);
cout << month << "/" << day << "/" << year << endl;
number = ckDate(month, day, year);
displayMsg(number);
}
_getch;
return 0;
}

void getDate(int& month, int& day, int& year)
{
cout << "Enter a date in the format mm/dd/yyyy (please do not add a 0 in front of single digit numbers)" << endl;
cout << "Enter month (1 - 12): "; cin >> month;
cout << endl;
cout << "Enter day (1 - 31): "; cin >> day;
cout << endl;
cout << "Enter year: (1000 - 9999) "; cin >> year;
cout << endl;
}

int ckDate( int month, int day, int year)
{
int daysPerMonth, number;
getDate (month, day, year);

switch (month){
case 1: case 3: case 5: case 7:case 8: case 10: case 12 : daysPerMonth=31;
break;
case 4: case 6: case9: case 11 : daysPerMonth=30;
break;
case 2 : if(((year%4==0)&&(year%100!=0))||(year%400==0)) daysPerMonth=29;
else
daysPerMonth=28;

if (day >= 1 && day <= daysPerMonth && month >= 1 && month <= 12 && year >= 1000 && year <= 9999)
{
number = 0;
}
else if ((year < 1000) || (year > 9999))
{
number = 1;
}
else if (month < 1 || month > 12)
{
number = 2;
}
else if ( day < 1 || day > daysPerMonth && daysPerMonth = 31)
{
number = 3;
}
else if ( day < 1 || day > daysPerMonth && daysPerMonth = 30 )
{
number = 4;
}
else if ( day < 1 || day > daysPerMonth && daysPerMonth = 29)
{
number = 5;
}
else if (day < 1 || day > daysPerMonth && daysPerMonth = 28)
{
number = 6;
}
return number;

}

void displayMsg (int number)
{
if ( number = 0)
{
cout << "Good Date \n";
}
if ( number = 1)
{
cout << "Bad Year \n";
}
if ( number = 2)
{
cout << "Bad Month not 1 - 12 \n";
}
if ( number = 3)
{
cout << "Bad Day not 1 - 31 \n";
}
if ( number = 4)
{
cout << "Bad Day not 1 - 30 \n";
}
if ( number = 5)
{
cout << "Bad Day not 1 - 29 \n";
}
if ( number = 6)
{
cout << "Bad Day not 1 - 28 \n";
}
}

in the int ckDate function in the compiler all the parts that say day are under lined and say it needs to be modifiable, what am I doing wrong?
Topic archived. No new replies allowed.