Answer to Question #17298 in Java | JSP | JSF for Tamara

Question #17298
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) .
Expert's answer
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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS
paypal