I'm trying to learn java. So I'm practicing what I've learned so far by making a calculator to do formulas I learned in my finance class.
But it's not working right now.

Code (Text):

case ("loan length"):
Scanner inp_ll = new Scanner(System.in);
System.out.print("What is the monthly payment? ");
monthlypmt = inp_ll.nextDouble();
System.out.print("What is the rate? ");
percent = inp_ll.nextDouble();
rate = percent/100;
System.out.print("What is the loan amount? ");
principal = inp_ll.nextDouble();
answer = (Math.log(monthlypmt/principal)-Math.log((monthlypmt/principal)-(rate/12)))/12*Math.log(1+rate/12);
System.out.print(("The loan length is: ")+ (answer));
break;

Here's one input I tested

And then another input using bigger numbers yields

Did I just do the formula wrong?
I looked it over a bunch and it looks right to me.
I even erased it and tried typing it in again.

Here's the original formula

where ln is natural log, m is monthly payment, p is principal and r is rate.

Java has some interesting gotchas too like when you use == vs = or && vs & ... that may not issue compile-time errors but do something quite unexpected because you typed in the wrong operator.