I'm a student and I was wondering if anybody can help me debug one of my functions. For this program the user is suppose to input two dates in the format mm/dd/yy between the years of 1972-2071 and the program is suppose to output the difference between those two dates. All of my functions work except for the function that calculates the amount of days from 1/1/72. This is the way our professor would like us to do it with no extra features. Just a beginner version with a lot of if else statements and for loops.
int ChangeToNumber(int m, int d, int y)
{
int total=0;
if(y<=71) //if the year is between 2000-2071
{
y+=28;
for(int i=0; i<y; i++)
{
if(!LeapYear(y))
{
total+=365;
}
else
{
total+=366;
}
}
}
else //if the year is between 1972-1999
{
for(int i=72; i<y; i++)
{
if(!LeapYear(y))
{
total+=365;
}
else
{
total+=366;
}
}
}
for(int i=1; i<m; i++)
{
total+=DaysInMonth(m, y);
}
total += d;
return total;
}