# 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) .

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;

}

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;

}

## Comments

## Leave a comment