Question: Write a method called hasMidpoint that accepts three integers as parameters and returns true if one of the integers is the midpoint between the other

Write a method called hasMidpoint that accepts three integers as parameters and returns true if one of the integers is the midpoint between the other two integers; that is, if one integer is exactly halfway between them. Your method should return false if no such midpoint relationship exists. For example, the call hasMidpoint(7, 4, 10) should return true because 7 is halfway between 4 and 10. By contrast, the call hasMidpoint(9, 15, 8) should return false because no integer is halfway between the other two. The integers could be passed in any order; the midpoint could be the 1st, 2nd, or 3rd. You must check all cases. If your method is passed three of the same value, return true.

Step by Step Solution

3.35 Rating (164 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public static boolean hasMidpoint int a int b int c double m... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!

Related Book