编写 EMI 计算器程序

碧海醫心
发布: 2024-11-18 08:06:13
转载
958人浏览过

编写 emi 计算器程序

emi 计算器:

emi 计算器可帮助您轻松估算每月分期付款。一旦您输入必要的详细信息,例如贷款金额、贷款期限和利率,银行的 emi 计算器将立即显示您估计的等值每月分期付款 (emi)。

要计算 emi,您可以使用以下公式:

emi = [p x r x ( 1 + r )^n] / [( 1 + r )^n -1]

地点:

p = 本金

r = 月利率(年利率/12个月)

n = 贷款期限(以月为单位)

示例:

# input the loan amount
loan = int(input("enter the loan amount: "))

# input the loan tenure in years and convert to months
tenure_year = int(input("enter the loan tenure in years: "))
tenure_month = tenure_year * 12  # convert years to months
print("loan tenure in months:", tenure_month)

# input the interest rate per year and convert to monthly interest rate
interest_year = float(input("enter the interest per year: "))
interest_month = interest_year / 12 / 100  # convert annual interest rate to monthly decimal rate
print("interest per month in percentage:", interest_month)

# calculate emi using the formula
emi = loan * (interest_month * (1 + interest_month) ** tenure_month) / ((1 + interest_month) ** tenure_month - 1)

# display the calculated emi, rounded to 2 decimal places
print("emi:", round(emi, 2))
登录后复制

输出:

Enter the loan amount:500000
Enter the loan tenure in years :10
Loan tenure in months: 120
Enter the interest per year:3.5
Interest per month in percentage: 0.002916666666666667
EMI: 4944.29


登录后复制

以上就是编写 EMI 计算器程序的详细内容,更多请关注php中文网其它相关文章!

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:dev.to网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号