I am getting an error message that the "isEven"method must return a result of type "int". This is after including a return statement, the error goes away if Include one more return statement. I am guessing its because of the "if-else" structure, but I want to only capture the even numbers. Can someone help me by telling me what I am doing wrong and how to fix this.
/*
* Printing factorials of all even numbers in a range
*/
import acm.program.*;
public class evenNumberTable extends ConsoleProgram{
public void run()
{
int ll=readInt("Enter the lower limit of the range: ");
int ul=readInt("Enter the upper limit of the range: ");
for(int i=ll;i<=ul;i++)
{
println(factorial(isEven(i));
}
}
private int isEven(int n){
if (n % 2==0) return n;
}
private int factorial(int n){
int result = 1;
for (int i=1;i<=n;i++){
result = result*i;
}
return result;
}