Here is the error:
- Code: Select all
error C2660: 'monthNums' : function does not take 3 arguments - 212
Here is my full code:
- Code: Select all
// This program will be used to print a calendar for any given year and the day of the week
#include <iostream>
#include <iomanip>
void printCal(int year, int start);
using namespace std;
//Function 1
//Prints Calendar
void printCal(int year, int start, int monthDays, int spacerDays, int prevSpacer, int dayCount = 1, int colCount = 0)
{
void monthNames(int count);
void dayNames();
void monthNums(int count, int& monthDays, int& spacerDays);
void spacer(int start, int& colCount, int count, int& prevSpacer);
void wrapper(int dayCount, int monthDays);
int count;
for (count = 1; count <= 12; count++)
{
monthNames(count);
dayNames();
monthNums(count, monthDays, spacerDays);
spacer(start, colCount, count, prevSpacer);
wrapper(dayCount, monthDays);
}
}
//Function 2
//Makes The Lines Return
void wrapper(int dayCount, int monthDays, int colCount)
{
while (dayCount <= monthDays)
{
if (colCount == 7)
{
cout << endl;
colCount = 0;
}
cout << setw(3);
cout << dayCount;
colCount++;
dayCount++;
}
colCount = 0;
cout << endl << endl;
}
//Function 3
//Checks For Leap Year
bool leapYear(int year)
{
if (year % 400 == 0)
{
return true;
}
if (year % 100 == 0)
{
return false;
}
if (year % 4 == 0)
{
return true;
}
return false;
}
//Function 4
//Previous And Current Days In Each Month
void monthNums(int& count, int& monthDays, int& spacerDays, int year, int monthCount)
{
switch (count)
{
case 1:
monthDays = 31;
break;
case 2:
if(leapYear(year))
//Check For Leap Year
monthDays = 29;
if(!leapYear(year))
monthDays = 28;
spacerDays = 31;
break;
case 3:
monthDays = 31;
if(leapYear(year))
//Check For Leap Year
spacerDays = 29;
if(!leapYear(year))
spacerDays = 28;
break;
case 4:
monthDays = 30;
spacerDays = 31;
break;
case 5:
monthDays = 31;
spacerDays = 30;
break;
case 6:
monthDays = 30;
spacerDays = 31;
break;
case 7:
monthDays = 31;
spacerDays = 30;
break;
case 8:
monthDays = 31;
spacerDays = 31;
break;
case 9:
monthDays = 30;
spacerDays = 31;
break;
case 10:
monthDays = 31;
spacerDays = 30;
break;
case 11:
monthDays = 30;
spacerDays = 31;
break;
case 12:
monthDays = 31;
spacerDays = 30;
break;
}
}
//Function 5
//Prints Out All Month Names
void monthNames(int count, int year)
{
switch (count)
{
case 1:
cout << " January " << year << endl;
break;
case 2:
cout << " February " << year << endl;
break;
case 3:
cout << " March " << year << endl;
break;
case 4:
cout << " April " << year << endl;
break;
case 5:
cout << " May " << year << endl;
break;
case 6:
cout << " June " << year << endl;
break;
case 7:
cout << " July " << year << endl;
break;
case 8:
cout << " August " << year << endl;
break;
case 9:
cout << " September " << year << endl;
break;
case 10:
cout << " October " << year << endl;
break;
case 11:
cout << " November " << year << endl;
break;
case 12:
cout << " December " << year << endl;
break;
}
}
//Function 6
//Prints Days And Indents Them Accordingly
void dayNames()
{
cout << " --------------------" << endl;
cout << " S M T W T F S" << endl;
}
//Function 7
//This Prints The Spaces Between Days and Months
void spacer(int start, int count, int& colCount, int& prevSpacer, int& monthDays, int& monthCount, int& spacerDays, int& year)
{
if (count == 1)
{
int loopCount;
for (loopCount = 0; loopCount < start; loopCount++)
{
cout << " ";
prevSpacer++;
}
colCount =+ start;
}
else if (count != 1)
{
int otherSpacer;
int loopCount;
int monthCount = count;
monthNums(monthCount, monthDays, spacerDays);
//Adds Number Of Spaces And Divides By 7
otherSpacer = (prevSpacer + spacerDays) % 7;
prevSpacer = 0;
for (loopCount = 0; loopCount < otherSpacer; loopCount++)
{
cout << " ";
prevSpacer++;
colCount =+ otherSpacer;
}
}
}
//Main Function
int main()
{
int year;
int start;
cout << "Please Enter Year To View The Calender: ";
cin >> year;
while(year <= 0)
{
cout<<"Please Enter A Valid Year (Larger Than 0): ";
cin >> year;
}
cout << endl << "0 - Sunday" << endl << "1 - Monday" << endl << "2 - Tuesday" << endl << "3 - Wednesday" << endl << "4 - Thursday" << endl << "5 - Friday" << endl << "6 - Saturday" << endl << endl;
cout << "Please Enter The Day Of The Week January 1st Falls On (See Above): ";
cin >> start;
cout << endl << endl << endl;
//Check To Make Sure User Entered A Correct Day
while ((start < 0) && (start > 6))
{
cout << endl << endl << endl;
cout << "You Entered An Incorrect Day. Please Enter An Integer Between 0-6.";
cin>>start;
}
printCal(year, start); // Calls The Function So That It Prints The Calender
cout << endl;
system("pause");
return(0);
}
