write method hasMidpoint that accept three integers as parameter ,and returns true if one of the numbers is the midpoint of the other two and returns false otherwise !
for example : the call hasMidpoint (3,7,5) return true because 5 is the midpoint of the other two
(3 and 7) .
public static boolean hasMidpoing(int one, int two, int three) {
if ((two + three)/2 == one){
return true;
}
else if ((one + three)/2 == two){
return true;
}
else if ((one + two)/2 == three){
return true;
}
return false;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
JavaJSPJSF