The Pair2
class (so called to distinguish it from an earlier assignment) takes two values as parameters in the constructor. The following methods are used to calculate and return results:
sum()
= the sum of the two valuesdifference()
= the difference between the two values (n1 - n2)product()
= the product of the two valuesaverage()
= the averagedistance()
= the distance (absolute value of the difference)max()
= the maximum (the larger of the two)min()
= the minimum (the smaller of the two)Then write a test program Pair2Tester.java
with a main()
method that demonstrates the use of the Pair2
class.