问题描述
我在c#和MySql中开发应用程序。需要帮助创建一个函数来计算利息延迟付款的罚款。
设A =金额= 1000,延迟付款利息= I = 1%,罚款= P. (每月付款)
如果A = 1000延迟一个月,P应为10.(1000/100 * 1%)
如果两个月延迟A = 1000,P应该是10 + 20(上个月罚款的两倍)。
如果三个月延迟A = 1000,P应为10 + 20 + 40
如果延迟四个月P则应为10 + 20 + 40 + 80
如果延迟五个月那么P应该是10 + 20 + 40 + 80 + 160
如果延迟六个月那么P应该是10 + 20 + 40 + 80 + 160 + 320
我没有想到实现这个。任何专家的想法将有助于使用存储过程(MySql)或c#中的函数。
ACUBE。
I developing a application in c# and MySql. Need help for creating a function to calculate penalty for delayed payment with interest.
Let A=Amount =1000, Interest for delay payment =I= 1%, Penalty=P. (Monthly Payment)
if one month delay for A=1000, P should be 10. (1000/100 *1%)
if two months delay for A=1000, P should be 10 + 20(double the Previous month Penalty).
if three months delay for A=1000, P should be 10 + 20 + 40
if four months delay for then P should be 10 + 20 + 40 + 80
if five months delay then P should be 10 + 20 + 40 + 80 + 160
if six months delay then P should be 10 + 20 + 40 + 80 + 160 + 320
I am not getting any idea to implement this.. Any expert ideas will be helpful using stored procedure (MySql) or functions in c#.
ACUBE.
推荐答案
P = A * I + 2 * P;
double P = 0.0;
int monthsDelayed = 4;
for (int i = 0; i < monthsDelayed; i++)
{
P = A * I + 2 * P;
}
当然也可以在没有循环的情况下完成。
Of course it can be done without the loop as well.
int monthsDelayed = 4;
double P = A * I * (Math.Pow(2, monthsDelayed) - 1);
(长时间没有做太多的数学运算所以我花了一段时间才看到模式)
(Haven't done much math in a long time so it took me a while to see the pattern)
这篇关于延迟付款中罚款计算的存储程序或功能 - 月的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!