# Practice it CSE142 MT 06au 的一道题

Write a method named 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.
The integers could be passed in any order; the midpoint could be the 1st, 2nd, or 3rd. You must check all cases.
Calls such as the following should return true:
hasMidpoint(4, 6, 8)
hasMidpoint(2, 10, 6)
hasMidpoint(8, 8, 8)
hasMidpoint(25, 10, -5)
Calls such as the following should return false:
hasMidpoint(3, 1, 3)
hasMidpoint(1, 3, 1)
hasMidpoint(21, 9, 58)
hasMidpoint(2, 8, 16)
=========================================================

=========================================================

```public static boolean hasMidpoint(int a,int b,int c){
int e=a+b+c;
if (e/3==a||e/3==b||e/3==c)
return true;
return false;
}```

=============================================================

# name expected return your return result
1 hasMidpoint(1, 2, 3) true true pass
2 hasMidpoint(2, 10, 6) true true pass
3 hasMidpoint(0, -50, -25) true true pass
4 hasMidpoint(21, 9, 58) false false pass
5 hasMidpoint(-2, 9, 27) false false pass
=================================================

==================================================

```public class test{
public static void main(String[] args){
System.out.println(hasMidpoint(0,-51,-25));
}
public static boolean hasMidpoint(int a,int b,int c){
int e=a+b+c;
if (e/3==a||e/3==b||e/3==c)
return true;
return false;
}
}```

//由于是复制过来的，就不能保持很好的代码格式了。

=============================================================

=============================================================

=================================================

`if ((e/3==a||e/3==b||e/3==c)&&e%3==0)`

`System.out.println(hasMidpoint(0,-501,-250));`

=================================================