Problem:
Given three ints, a b c, return true if b is greater than a, and c is greater than b. However, with the exception that if "bOk" is true, b does not need to be greater than a.
inOrder(1, 2, 4, false) → true
inOrder(1, 2, 1, false) → false
inOrder(1, 1, 2, true) → true
Solution:
public boolean inOrder(int a, int b, int c, boolean bOk) { if(bOk) { if (c > b) return true; else return false; } if (b > a && c > b) return true; else return false; }
if (bOk){
ReplyDeletereturn (b<c);
}
return (a<b && b<c);
Shorter...
return (bOk) ? (b<c) : (a<b && b<c);
ReplyDeleteif (bOk)
ReplyDeletereturn (c > b);
return (b > a && c > b);
i was analyzing a number of your content material harshly this website and that i conceive this net web page is in reality informative ! hold whilst inspiration to setting happening. Young Thug Net Worth
ReplyDeletereturn ((!equalOk)? (a<b && b<c) : (a<=b && b<=c));
ReplyDeletepublic boolean inOrder(int a, int b, int c, boolean bOk) {
ReplyDeletereturn (bOk || a < b) && (b < c);
}
return ((c>b)&&(b>a||bOk));
ReplyDeleteUseful solution
ReplyDelete