Hi Dogma,
You had a few things going on here that needed fixing. The error wasn't helping you much in diagnosing everything. Here is a working version for you...
CODE
import java.text.DecimalFormat;
import java.text.NumberFormat;
public class MortgageCalculator
{
public static void main (String[] args)
{
//variables
DecimalFormat decimalPlaces=new DecimalFormat("0.00");
double periods,principle,interest,payment;
int amount;
interest=.0575;
principle=200000.0;
periods=30.0;
payment = principle * ((interest / 12.0) / (1.0 - Math.pow( (1.0 + (interest / 12.0)), -periods) ) );
//Output
System.out.println("Principle="+principle);
System.out.println("interest rate="+interest*100);
System.out.println("Payments="+periods);
System.out.println("Payment="+payment);
System.out.println(decimalPlaces.format(payment));
}
}
Here are the changes I made... principle and periods were defined as double, so you should make sure you put a decimal into them. Next, you were using an integer (1) when dealing with calculations in double. So just make them 1.0.
Next payment was defined as an integer, it should be double because the calculation at the end will be double. So I moved it to the double definition list.
Then in your formula, you were not defining the "second" parameter in pow()... the exponent. So I put in the comma before -periods to make it your power. This made it to the power of negative 30.
Also notice that I moved a parenthesis or two to make the correct order of operations to compensate for the new comma I put in.
After running this code I got a total of $7,173.24 as a mortgage payment which will result in paying $215,197.20 over the 30 months. That is over 15,000 in interest! Which sounds about right for a 200,000 principle over almost 3 years of payments.
Hope this all makes sense!