Calendar program to count the days...

I am a very new programmer and am working on an assignment to create a program that counts the days from Jan 1, 2010 to a given date. I am doing great so far, but stuck on my second loop. The first works to receive the month and give an error message, but the second one (to receive the day) is messed up. I think it's a problem with my order of things but I can't seem to fix it. Can someone look at my code and maybe tell me where I'm going wrong? Thanks so much.
Here it is: (you can ignore the leap year part for now)
#include <iostream>
#include <string>
using namespace std;

int day, maxDay, month, total=0;
unsigned short int days_per_month[12]={31,28,31,30,31,30,31,31,30,31,30,31};
string monthName[12]={ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

int main()
{
cout << "This program calculates the number of days from Jan 1, 2010 to a date in the \nyear 2010 that you specify." << endl;
cout << "Please enter a month (1-12): " << endl;
cin >> month;
while (month< 1 || month >12)
{
cout << month << " is not a valid entry for the month. Please enter a value between 1 and 12: " << endl;
cin >> month;
}
cout << "Please enter a day of the month: " << endl;
cin>>day;

if (month == 4 || month == 6 || month == 9 || month == 11)
{
maxDay = 30;
}
else if (month == 2)
//{
// bool isLeapYear = (year% 4 == 0 && year % 100 != 0) || (year % 400 == 0);
// if (isLeapYear)
// {
// maxDay = 29;
// }
//else
{
maxDay = 28;
}

else
{
maxDay = 31;
}
while (day>maxDay);
{
cout << day << " is not a valid day in the month of " << monthName[month-1] <<"." << endl;
cout << "Please enter a value between 1 and " << maxDay << endl;
cin >> day;
}

total=day;
for(int x=0;x<month-1;x++)
total+=days_per_month[x];
cout << total << " days elapse between January 1, 2010 and " << monthName[month-1] <<" " << day << ", 2010" << endl;
return 0;

}


:) You have a semicolon after: while (day>maxDay)

Topic archived. No new replies allowed.