C
Charles
I am creating a program, but keep receiving the same error what I am
trying to do is have it output a calendar. I have it where it outputs
the month name and year inputted, and the days of the week. I can not
however get it to return a value. It says "cannot return a value from
method whose result type is void". If I change it to anything else I
get the error "missing return statement". I have already been to:
http://java.sun.com/docs/books/tutorial/java/javaOO/methoddecl.html#returnvalue
That site was no help at all. Here it the part of the program I am
trying to get to work.
/**********************************************
* Get number of days in a month.
***********************************************/
// THIS IS THE PROBLEM AREA!!!
public void numOfDaysInMonth()
//
{
if ((month == 1) || (month == 3) || (month == 5) || (month == 7) ||
(month == 8) || (month == 10) || (month == 12))
return 31;
if ((month == 4) || (month == 6) || (month == 9) || (month == 11))
return 30;
if ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)))
year = isLeapYear;
if (month == 2)
if(isLeapYear == year)
return 29;
else
return 28;
for (row = 0; row < 5; row++)
{
for (column = 0; column < 7; column++)
monthly[row][column] = column + row;
}
for (int i = 1800; i < year; i++)
{
if (isLeapYear == isLeapYear)
total = total + 366;
else
total = total + 365;
}
for (row = 0; row < 5; row++)
{
for (column = 0; column < 7; column++)
System.out.print(" " + monthly[row][column]+ " ");
System.out.println();
}
}
}
trying to do is have it output a calendar. I have it where it outputs
the month name and year inputted, and the days of the week. I can not
however get it to return a value. It says "cannot return a value from
method whose result type is void". If I change it to anything else I
get the error "missing return statement". I have already been to:
http://java.sun.com/docs/books/tutorial/java/javaOO/methoddecl.html#returnvalue
That site was no help at all. Here it the part of the program I am
trying to get to work.
/**********************************************
* Get number of days in a month.
***********************************************/
// THIS IS THE PROBLEM AREA!!!
public void numOfDaysInMonth()
//
{
if ((month == 1) || (month == 3) || (month == 5) || (month == 7) ||
(month == 8) || (month == 10) || (month == 12))
return 31;
if ((month == 4) || (month == 6) || (month == 9) || (month == 11))
return 30;
if ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)))
year = isLeapYear;
if (month == 2)
if(isLeapYear == year)
return 29;
else
return 28;
for (row = 0; row < 5; row++)
{
for (column = 0; column < 7; column++)
monthly[row][column] = column + row;
}
for (int i = 1800; i < year; i++)
{
if (isLeapYear == isLeapYear)
total = total + 366;
else
total = total + 365;
}
for (row = 0; row < 5; row++)
{
for (column = 0; column < 7; column++)
System.out.print(" " + monthly[row][column]+ " ");
System.out.println();
}
}
}