calendar

ok, i'm working on this calendar program, and i've searched around here on thise site for similiar posts, but in the other calendar programs i don't get what they are doing, so i've been writing this, and am almost done with it just needs a few things

#include <iostream>
#include <iomanip>
using namespace std;

/***************************************************
* Gets the month from the user and will verify if
* the month is valid or not.
****************************************************/
int getMonth ()
{
int month;
cout << "Enter the month: ";
cin >> month;
while (month >= 13 || month <= 0)
{
cout << "Month must be between 1 and 12.\n";
cout << "Enter the month: ";
cin >> month;
}
return month;
} //getMonth function end

/***************************************************
* Gets the year from the user and will verify if it
* is valid or not.
****************************************************/
int getYear ()
{
int year;
cout << "Enter year: ";
cin >> year;
while (year < 1753)
{
cout << "Year must be 1753 or later. \n";
cout << "Enter year: ";
cin >> year;
}
return year;
} //getYear function end.


/***************************************************
* Takes the year the user enters and determines if
* it is a leap year or not.
****************************************************/
bool leapYear (int year)
{
bool leapDay;
if (year % 400 == 0)
leapDay = true;

else if (year % 100 == 0)
leapDay = false;

else if( year % 4 == 0)
leapDay = true;

else
false;

return leapDay;
} //leapYear function ends.

/***************************************************
* Takes the month from the user and determines how
* many days the month has in it.
****************************************************/
int calcDays (int month, bool isLeapYear)
{
int howManyDays;
if (month == 1 ||
month == 3 ||
month == 5 ||
month == 7 ||
month == 8 ||
month == 10 ||
month == 11 ||
month == 12)
howManyDays = 31;

else if (month == 4 ||
month == 6 ||
month == 9 ||
month == 11)
howManyDays = 30;

else if (month == 2 && isLeapYear == true)
howManyDays = 29;
else
howManyDays = 28;

return howManyDays;
} //calcDays function ends.


/***************************************************
* This function determines on which day the month
* should start entered in by the user, also takes
* into consideration leap years.
****************************************************/
int calcStartDay (int days, int month, int year, bool leap)
{
// local declarations
int yearCount = 0;
int monthCount = 0;
int calcYear = 0;
int calcMonth =0;
int start = 1;

// local statements
for (yearCount = 1753; yearCount < year; yearCount++)
{
start += 365;
if (leapYear(yearCount))
{
start++;
}
start = start % 7;
}

for (monthCount = 1; monthCount < month; monthCount++)
{
start += calcDays(monthCount, leap);
}
start = start % 7;

return start ;

} // start_day function end



/***************************************************
* Takes the Numeric month given by the user, and
* changes it to which month it is in english.
****************************************************/
string calcMonth (int month)
{
string monthName;
switch (month)
{
case 12:
monthName = "December";
break;
case 11:
monthName = "November";
break;
case 10:
monthName = "October";
break;
case 9:
monthName = "September";
break;
case 8:
monthName = "August";
break;
case 7:
monthName = "July";
break;
case 6:
monthName = "June";
break;
case 5:
monthName = "May";
break;
case 4:
monthName = "April";
break;
case 3:
monthName = "March";
break;
case 2:
monthName = "Februaruy";
break;
case 1:
monthName = "January";
break;

default:
;
}
return monthName;
} //calcMonth function ends

/***************************************************
* Outputs the calendar to the screen.
* the month the year and days in the month
****************************************************/
void outputCalendar (int month, int year, int howManyDays, string monthName)
{
cout << monthName << ", " << year << endl;
cout << setw(2) << " S " << " M " << " Tu " << " W "
<< " Th " << " F " << " S " << endl;
/*int days = 0;
for (int dayCount = 1; dayCount <= howManyDays; dayCount++)
{
days += dayCount;
cout << setw(2) << days;
}
*/

return;
} //end of the outputCalendar function.

int main ()
{int me;
int month;
int year;
bool leap;
int days;
int startDay;
int howManyDays;
string monthName;

month = getMonth ();
year = getYear ();
leap = leapYear (year);
days = calcDays (month, leap);
startDay = calcStartDay (days, month, year, leap);
monthName = calcMonth (month);
outputCalendar (month, year, howManyDays, monthName);

cout << startDay << endl << endl; // Remove me!!!
cin >> me;
return 0;
}

the startday isn't quite working right, i've tried playing around with it and haven't gotten it to work, the year needs to be 1753 then go on from there
and then the last one is how to print off the days on the calendar, i tried with a loop, but it just keeps going for some reason. any help would be appreciated, thanks guys!
[7234 byte] By [shooter23000] at [2007-11-20 11:49:40]
# 1 Re: calendar
why in calcStartDay have you got the variable start initialised to 5? 1st January 1753 was a Monday. I think if you change it to:

int start = 0;

it should work.

BJW
sockman at 2007-11-9 1:26:17 >
# 2 Re: calendar
whoops i was playing around with it and forgot to take that off from there
shooter23000 at 2007-11-9 1:27:20 >