class Main { public static void main(String[] args) { // testing the equals() method double angle = 89.999999; System.out.println(equals(angle, 90.0, 0.001)); // should be equal System.out.println(equals(angle, 91.0, 0.001)); // should be unequal } // end main() /** * equals is used to compare two real numbers for equality to within * a specified tolerance * * @author Peter Gehbauer * @version 1.0 March 2, 2021 * * @param value the number to be compared * @param target the number being compared to * @param tolerance the maximum difference allowed for value to be considered equal to target * * @return true if value is within tolerance of target; false otherwise */ private static boolean equals(double value, double target, double tolerance) { return (Math.abs(value-target) < tolerance); } // end equals () } // end class Main