# code

code

August 28, 2010 - 02:39
Here is the question: Given 2 int values, return true if one is negative and one is positive. Unless the parameter "negative" is true, then they both must be negative.

it return true only if one is negative and one is positive ?

Given answer :

public boolean posNeg(int a, int b, boolean negative) {

if (negative) {

return (a < 0 && b < 0);

}

else {

return ((a < 0 && b > 0) || (a > 0 && b < 0));

}

}