So I have this homework question where it asks me to make a power formula using e^(Y * log(X)) and my pow method. I have done my pow method and it works, just having some difficulty with the equation method.

For example, if I put in 7 and 5

I should get the answer 16806.9999999 for the expression and for my pow 16806. I'm not getting that answer for the expression.

double one;
double two;

System.out.println("Enter your first number");
one = sc.nextDouble();

System.out.println("Entr your second number");
two = sc.nextDouble();

System.out.println("using the formula your number is " + Math.log(Math.pow(one, 1) * Math.log(two)));
System.out.println("using myPow " + Math.pow(one, two));

1 Answers

RCaetano On

It seems you may have a wrong formula. Instead of Math.log(Math.pow(one, 1) * Math.log(two)) you should have Math.exp(two * Math.log(one)) maybe?