我正在创建付款的自动计算。但我不知道它的公式。单击计算付款按钮后,它将自动计算本金,付款数量和利息,然后在付款时输出。
请参阅屏幕截图
// Example1 Computation
Principal 100000
Number of Payments 9
Interest 2
//Then when the calculate payment is click, execute
Payment 12251.54
// Example2 Computation
Principal 200000
Number of Payments 8
Interest 3.5
//Then when the calculate payment is click, execute
Payment 29095.33
// Example3 Computation
Principal 150000
Number of Payments 12
Interest 1.5
//Then when the calculate payment is click, execute
Payment 13752.00
这是我的字符串
String principal = txt_principal.Text;
String numberofPayments = txt_nop.Text;
String interestRate = txt_irpp.Text;
String payment = txt_payment.Text;
请帮帮我。提前谢谢!
答案 0 :(得分:1)
答案在这里:
https://en.wikipedia.org/wiki/Compound_interest
Excel可以为您执行此操作:=PMT(0.02,9,100000)
公式如下:
Where:
PV = 100000 (principal)
RATE = 0.02 (interest)
NPER = 9 (payments)
PMT = -RATE * ( PV * Math.Pow(1+RATE,NPER)) / ((Math.Pow(1+RATE,NPER)-1));
所以对于你的代码:
double PV = double .Parse(txt_principal.Text);
double NPER = double .Parse(txt_nop.Text);
double RATE = double.Parse(txt_irpp.Text) / 100;
double PMT = -RATE * ( PV * Math.Pow(1+RATE,NPER)) / ((Math.Pow(1+RATE,NPER)-1));
txt_payment.Text = (-PMT).ToString();