/** BoxAreaTester.java tests the surface area method of Box.java. * in the face of possible roundoff errors. * Compile normally, run with assert enabled: * java -ea BoxAreaTester */ public class BoxAreaTester { public static void main(String[] args) { new BoxAreaTester().testArea(); } public void testArea() { System.out.print("Testing Box.surfaceArea(): "); Box aBox = new Box(2.0, 3.0, 4.0); // test 1 double area = aBox.surfaceArea(); assert Math.abs(area - 52.0) < 3.0e-10; System.out.print(" 1 "); aBox = new Box(6.0, 5.0, 4.0); // test 2 area = aBox.surfaceArea(); assert Math.abs(area - 148.0) < 3.0e-10; System.out.print(" 2 "); aBox = new Box(6.0*2.54, 5.0*2.54, 4.0*2.54); // test 3, // convert inches to centimetres. area = aBox.surfaceArea(); assert Math.abs(area - 148.0*Math.pow(2.54, 2)) < 3.0e-10; System.out.print(" 3 "); System.out.println(" Passed!"); } }