Consider the following algorithm for computing xn for an integer n. If n < 0, xn is 1/xn. If n is positive and even, then xn = (xn/2)2. If n is positive and odd, then xn = xn−1 · x. Implement a static method double intPower(double x, int n) that uses this algorithm. Add it to a class called Numeric.

Complete the following files:

Numeric.java

PowerTester2.java

Use the following file:

PowerTester.java

/**
   This is a test driver for the intPower method.
*/
public class PowerTester
{
   public static void main(String[] args)
   {
      System.out.println(Numeric.intPower(0.1, 12));
      System.out.println("Expected: " + 1E-12);
      System.out.println(Numeric.intPower(2, 10));
      System.out.println("Expected: 1024");
      System.out.println(Numeric.intPower(-1, 1000));
      System.out.println("Expected: 1");
   }
}