After taking your advice and a little more searching I got the following code that runs and decrements great. Suddenly I realize that my algorithm isn't working. It's supposed to calculate the loan over 360 months (30 years), but my code runs the pricipal to zero in 189 months. And it looks like the reason is that it is calculating the interest wrong.
I'm about to lose my mind on this project.
Code:
import java.text.*;
class Wk3
{
public static void main (String[] arguments) //create main
{
int term = 30; //init var for length of loan
double rate = .0575; //init var for interest rate
double amount = 200000; //init var for loan amt
double pmt = 0;
rate = (rate/12); //divide annual rate to get monthly rate
term = (term * 12); //multiply years to get length in months
pmt= amount * ((rate) / (1-Math.pow(1 + rate, - term))); //compute payment
while (amount > 0 & term > 0 ) //run if counter >0
{
java.text.DecimalFormat dec = new java.text.DecimalFormat(",###.00"); //format next output to dollars.cents
System.out.println("\nThis months payment is $" + dec.format (pmt)); //display payment
System.out.println ("\nYour loan balance is $" + dec.format (amount)); //display loan amt
System.out.println("\nThis months interest is $" + dec.format (amount * (rate ))); //montly interest payment
System.out.println("\nThis months term is " + (term));
term --;
amount -= pmt;
}
}
}