I am working this program and it is now giving me a error that I do not know how to resolve. The exact error says error C2064 term does not evaluate to a function taking 3 arguments. I did move the initialization of the dayNumber function inside of the getDate function. That is when this error started. I appreciate any help I can get. Any other suggestions on modifing this code will also be appreciated.
Thanks Kerry
Here is the code (sorry it is so long)
CODE
//Kerry Cain
//Sequence Assn. Part 3
//displays the character entered as well as its ASCII value
#include <iostream>
#include <iomanip>
using namespace std;
void getDate ();
int validDate (int&, int&, int&);
int dayNumber (int&, int&, int&);
bool isLeapyear (int year);
int main()
{
int month;
int day;
int year;
cout << "\nThis program will read in a date and return the date \n";
cout << "\nIt will also display the number the day is of that year "<< endl;
cout << "\nThe year must be between 1 and 3000 " << endl;
cout << "\n";
getDate ();
return 0;
}
void getDate ()
{
char Y;
char cont = Y;
while (cont != 'N')
{
int month;
int day;
int year;
char b;
int daycount;
int dayNumber;
cout << "\nPlease enter a date in the form month/day/year: ";
cin >> month >> b >> day >> b >> year;
cout <<endl;
validDate (month, day, year);
dayNumber (month, day, year);
cout << setw (2) << setfill ('0') << day << "-";
switch (month)
{
case 1:
cout <<"January";
break;
case 2:
cout <<"February";
break;
case 3:
cout <<"March";
break;
case 4:
cout <<"April";
break;
case 5:
cout <<"May";
break;
case 6:
cout <<"June";
break;
case 7:
cout <<"July";
break;
case 8:
cout <<"August";
break;
case 9:
cout <<"September";
break;
case 10:
cout <<"October";
break;
case 11:
cout <<"November";
break;
case 12:
cout <<"December";
break;
}
cout << "-";
cout << setw (4) << setfill ('0') << year;
cout << " is day number "<<day<< " in year "<<year<<endl;
cout <<endl;
cout << "If you wish to exit program please enter N to keep going enter Y: ";
cin >>cont;
cout <<endl;
}
return;
}
bool isLeapyear (int year)
{
if (year % 400 == 0 || ( year % 4 == 0 && year % 100 != 0 ) )
return true;
else
return false;
}
int validDate (int& month, int& day, int& year)
{
int daysinmonth = 0;
if (month >= 1 && month <=12)
{
}
else
{
cout <<"Error the month is not in the valid range!!"<<endl;
}
if (year >=1 && year <=3000)
{
;
}
else
{
cout <<"Error you have input an invalid year!! "<<endl;
}
if (month == 9|| month == 4 || month == 6 || month == 11)
{
daysinmonth = 30;
}
else if (month == 2)
{
if (isLeapyear(year))
daysinmonth = 29;
else
daysinmonth = 28;
}
else
{
daysinmonth = 31;
}
if (day < daysinmonth)
;
else
{
cout <<"Error you have input an invalid day number!! "<<endl;
}
return (daysinmonth);
}
int dayNumber (int& month, int& day, int& year)
{
int daycount = day;
if (month > 1)
daycount = daycount + 31;
if (month > 2)
{
if (isLeapyear (year))
daycount = daycount + 29;
else
daycount = daycount + 28;
}
if (month > 3)
daycount = daycount + 31;
if (month > 4)
daycount = daycount + 30;
if (month > 5)
daycount = daycount + 31;
if (month > 6)
daycount = daycount + 30;
if (month > 7)
daycount = daycount + 31;
if (month > 8)
daycount = daycount + 31;
if (month > 9)
daycount = daycount + 30;
if (month > 10)
daycount = daycount + 31;
if (month > 11)
daycount = daycount + 30;
cout <<"daycount is now "<<daycount<<endl;
return (daycount);
}