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 to is if one integer is exactly between the two others. The method should return false if no such midpoint relationship exists. For example, (7,4,10) should return false.
Below is what I've written down currently, although I haven't been able to get it to work yet. I've got the number inputs and am but can't get it to run my method at the end, which I think is correct. Any help would be appreciated. Thanks!
import java.util.*;
public class midPoint1{
public static void main(String[]args) {
int a, b, c;
Scanner console = new Scanner(System.in);
System.out.println("Enter a number: ");
a = console.nextInt();
System.out.println("Enter a second number: ");
b = console.nextInt();
System.out.println("Enter a third number: ");
c = console.nextInt();
hasMidpoint(a, b, c);
}
public static boolean hasMidpoint(int a, int b, int c) {
int midpoint = a + c;
if(b == midpoint) return true;
else
return false;
}
}