График амортизации: monthlyprincipal не правильно рассчитан
I am trying to calculate the Amortization Schedule. The monthly Payments are being calculated in a separate method monthlyPayments() . I compared it with a Amortization Schedule calculator online and the problem is while the principle balance(newPrincipleBalance), monthlyInterest , EMI(monthly payments) are being calculated correctly , the monthlyPrincipal is not. It keeps decreasing instead of increasing. What can I do to correct it? { double principal = 10000; double rate =0; double EMI; double monthlyInterest; double monthlyPrincipal; double newPrincipalBalance; for (int i = 0; i <= 24; i++) { Console.WriteLine("principal " + principal); EMI = Math.Round(monthlyPayments(principal, 5, 2)); Console.WriteLine("EMI " + EMI); monthlyInterest = (principal * rate) / 12; monthlyInterest = Math.Round((principal * 5 / 100) / 12); Console.WriteLine("monthlyInterest " + monthlyInterest); monthlyPrincipal = Math.Round(EMI - monthlyInterest); Console.WriteLine("monthlyPrincipal " + monthlyPrincipal); newPrincipalBalance = Math.Round(principal - monthlyPrincipal); Console.WriteLine("newPrincipalBalance " + newPrincipalBalance); Console.WriteLine("==================================="); principal = newPrincipalBalance; } } public static double monthlyPayments(double principal, double rate, int years) { rate = rate / 1200; years = years * 12; double F = (double)Math.Pow((double)(1 + rate), years); return principal * (rate * F) / (F - 1); }
Что я уже пробовал:
Я сравнил его с другими кодами в интернете, но до сих пор не могу понять, что случилось.
Patrice T
Показать входные данные, фактический выход и ожидаемый выход.