对于给定的问题,我在我的程序中做了什么?

sxpgvts3  于 2022-10-01  发布在  Java
关注(0)|答案(0)|浏览(78)

给出两个整数值,如果一个为负,一个为正,则返回TRUE。如果参数“Negative”为真,则仅当两者都为负时才返回TRUE。

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

if (negative == true)
   {
    if (a<0 && b<0)
     {
       return true;
     }
     else if((a<0 && b>0)||(a>0 &&b<0))
     {
    return true;
     }
    else{ return false;}
  }
  else
  {return false;}
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题