Hi,
I keep getting the error message "Missing return statement" after my if else controls.
I have return controls, I'm just not sure if I can implement multiple returns.
For example, I am trying to create a method in which the middle value of a sequence of numbers is returned, regardless of position. (E.g. 2, 1, 3 returns 2, -- 8, 3, 5 returns 5)
Here is my code below
public int mid(int a, int b, int c)
{
if ((a != b) && (a != c))
{
return a;
}
else if ((b != a) && (b != c))
{
return b;
}
else if ((c != a) && (c != b))
{
return c;
}
} (error message here)
Am I getting this error message simply because I have not covered all possible options in the if-else control, or is there another reason?