Hi all. Eventually my program needs to prompt you to enter a year between 1800-2007 and then it will print off the calendar for that year. In order to do this I must create functions that determine what day of the week Jan 1 was that year, and a function that prints a header for each month and a function that prints off the days of that month. For now, I just said the first day of each month was a Wednesday and that every month has 30 days. Before I figure out how to return the correct amount of days for each month and throw leap years into the equation, I would like help with a much simpler portion of my program. I can't get my program to print a different header for each month. On the very bottom of my program, where I have: void Print_Month_Head(int m)
if I just type cout << "\n January Sun Mon Tue Wed Thu Fri Sat\n";
My program will print a header for January on top of every month. So I tried implementing a for loop for 1<m<12 with an 'if' statement that lists a different cout prompt for every value of m, but when i run the program it just lists the header for january an infinite amount of times. My entire code is listed below, any help I can receive would be great, thanks!
#include <iostream>;
#include <iomanip>;
using std::cin;
using std::cout;
using std::endl;
using std::setw;
int First_Day_Of_Month(int y, int m);
int Number_Days_Of_Month(int y, int m);
void Print_Version();
void Print_Head(int y);
void Print_Month(int y, int m);
void Print_Month_Head(int m);
void main ()
{
Print_Version();
int year;
cin >> year;
Print_Head(year);
for(int i=1; i<=12; i++){
Print_Month(year, i);
}
cout << "bye";
}
void Print_Version()
{
cout << "Welcome \n";
}
void Print_Head(int y)
{
cout << " " << y << endl;
cout << "==================================================\n";
}
void Print_Month(int y, int m)
{
Print_Month_Head(m);
int firstday, number_days;
firstday = First_Day_Of_Month(y,m);
number_days = Number_Days_Of_Month(y,m);
cout << " ";
for (int k=0; k<firstday; k++)
cout << " ";
for (int i = 1; i<number_days; i++){
cout << setw(5) << i;
if ((i + firstday)%7 == 0){
cout << endl;
cout << " ";
}
}
}
int First_Day_Of_Month(int y, int m)
{
return 2;
}
int Number_Days_Of_Month(int y, int m)
{
return 30;
}
void Print_Month_Head(int m)
{
for (int i = 1; i<=12; i++)
{
if (i = 1)
{
cout << "\n January Sun Mon Tue Wed Thu Fri Sat\n";
}
else if (i = 2)
{
cout << "\n February Sun Mon Tue Wed Thu Fri Sat\n";
}
else if (i = 3)
{
cout << "\n March Sun Mon Tue Wed Thu Fri Sat\n";
}
else if (i = 4)
{
cout << "\n April Sun Mon Tue Wed Thu Fri Sat\n";
}
else if (i = 5)
{
cout << "\n May Sun Mon Tue Wed Thu Fri Sat\n";
}
else if (i = 6)
{
cout << "\n June Sun Mon Tue Wed Thu Fri Sat\n";
}
else if (i = 7)
{
cout << "\n July Sun Mon Tue Wed Thu Fri Sat\n";
}
else if (i = 8)
{
cout << "\n August Sun Mon Tue Wed Thu Fri Sat\n";
}
else if (i = 9)
{
cout << "\n September Sun Mon Tue Wed Thu Fri Sat\n";
}
else if (i = 10)
{
cout << "\n October Sun Mon Tue Wed Thu Fri Sat\n";
}
else if (i = 11)
{
cout << "\n November Sun Mon Tue Wed Thu Fri Sat\n";
}
else
{
cout << "\n December Sun Mon Tue Wed Thu Fri Sat\n";
}
}
}