延迟付款中罚款计算的存储程序或功能 - 月 [英] Stored procedure or function for Penalty Calculation in delay payment -Monthly

查看:78
本文介绍了延迟付款中罚款计算的存储程序或功能 - 月的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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.

推荐答案

这是一个非常简单的数学运算。



基本上你想要的是循环通过延迟的月数和计算每个月的利息总和+前一个值加倍。



Thi公式应该可以帮助你在学校工作。

(如果不是学校工作,那就有点可怕了)

This is a pretty simple math operation.

Basically what you want is to loop through the number of months delay and calculate the sum of the interest for each month + the previous value doubled.

This formula should help you along in your school work.
(if it is not school work it is a bit scary)
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)


这篇关于延迟付款中罚款计算的存储程序或功能 - 月的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆