当前位置:网站首页>Classic example of C language - loan balance
Classic example of C language - loan balance
2022-07-24 00:25:00 【Blue_ lan18】
Programming calculation first 、 second 、 The remaining loan amount after repayment in the third month :
# include <stdio.h>
int main()
{
double amount;// The total loan amount
double rate;// Annual interest rate
double monthlyPayment;// Monthly repayment amount
double firstPayment = 0;// Loan balance in the first month
double secondPayment = 0;
double thirdPayment = 0;
double monthlyRate = 0.01 * 6.0/12;// An interest
printf("Enter amount of loan: ");
scanf("%lf", &amount);
printf("Enter rate of loan: ");
scanf("%lf", &rate);
printf("Enter monthlyPayment of loan: ");
scanf("%lf", &monthlyPayment);
/* Keep two decimal places when displaying the balance after each repayment . Tips : The loan balance of each month minus the repayment amount ,
You also need to add the product of the loan balance and the monthly interest rate . The monthly interest rate is calculated by converting the interest rate entered by the user into a percentage and dividing it by 12.
*/
firstPayment = amount - monthlyPayment + amount * monthlyRate;
secondPayment = firstPayment - monthlyPayment + firstPayment * monthlyRate;
thirdPayment = secondPayment - monthlyPayment + secondPayment * monthlyRate;
printf("Balance remaining after first payment: %.2f\n",firstPayment);
printf("Balance remaining after second payment: %.2f\n", secondPayment);
printf("Balance remaining after third payment: %.2f\n", thirdPayment);
}
边栏推荐
猜你喜欢

php实现 Stripe订阅

High number_ Chapter 1 space analytic geometry and vector algebra__ Two point distance

Redis 主从、哨兵、集群架构有缺点比较

Multi data source configuration of mongodb

PayPal subscription process and API request

The universal esp32c3 configures partition tables based on the Arduino ide framework

PHP implements stripe subscription

Beifeng communication appeared in China (Xiamen) emergency exhibition | intelligent communication means are strong and eye-catching!

jenkins下使用声明式(Declarative)和Jenkinsfile的方式构建Pipeline流水线项目

Redis 集群hash分片算法(槽位定位算法)
随机推荐
As a programmer, is there anything you want to say to the newcomer?
Educational Codeforces Round 132 (Rated for Div. 2)(A-D)
GBase 8c 访问权限查询函数(三)
Application of SCA on devsecops platform
Gbase 8C access authority query function (I)
EFCore高级Saas系统下单DbContext如何支持不同数据库的迁移
CA digital certificate
Docker builds sonarqube, mysql5.7 environment
Detailed overview of data standards -2022
jenkins下使用声明式(Declarative)和Jenkinsfile的方式构建Pipeline流水线项目
paypal订阅流程及api请求
总结谋划明方向 凝心聚力开新局——和数软件对口援疆项目显成效
Redis 集群hash分片算法(槽位定位算法)
【电赛训练】非接触物体尺寸形态测量 2020年电赛G题
Table custom table encapsulation
Résumé du websocket minier
Pytest interface automated testing framework | how to get help
GBase 8c 会话信息函数(二)
采坑websocket總結
腾讯将关闭“幻核”,数字藏品领域发展是否面临阻力?