package examples;
public class LoanPayment {
public static void main(String args[]) {
double apr = 0.06;
double principle = 15000;
double numberOfMonths = 48;
double monthlyInterestRate = apr / 12;
double monthlyPayment =
principle * (monthlyInterestRate
/ (1 - Math.pow(1 + monthlyInterestRate, -numberOfMonths)));
double Q = 1;
for (int x = 1; Q > 0; x++) {
double H = principle * monthlyInterestRate;
double C = monthlyPayment - H;
Q = principle - C;
principle = Q;
}
System.out.println(
"The amount of your monthly payment is: " + monthlyPayment);
}
}