c语言 银行贷款的月利率 简单代码
#include stdio.h
#includemath.h
main()
{
double money,capital;
double rate[4]={0.009,0.01,0.0111,0.012};
int n;
printf("请输入本金和期限(年)\n");
scanf("%lf%d",capital,n);
if(n3)
money=capital*pow((1+rate[3]),12*n);
else
money=capital*pow((1+rate[n-1]),12*n);
printf("%d年后本金和利息合计为:%.2lf\n",n,money);
}
C++ C语言程序设计 题目:贷款计算器
/*
* main.c
*
* Created on: 2011-6-8
* Author: icelights
*/
#include stdio.h
#include stdlib.h
#include ctype.h
#include math.h
#define APR1 0.0747 /*1年(含1年)年利率*/
#define APR2 0.0756 /*1-3年(含3年)年利率*/
#define APR3 0.0774 /*3-5年(含5年)年利率*/
#define APR4 0.0783 /*5年以上年利率*/
#define A_TO_M 1/12 /*月利率 = 年利率 / 12*/
#define RTP 12 /*Reimbursement total periods还款总期数 =年限*12*/
#define LENGTH 80
struct LoanInfo
{
/*姓名*/
char name[LENGTH];
/*贷款总额*/
double LoanAmount;
/*贷款年限*/
double LoanYear;
/*月付*/
double MonthlyPayment;
/*总利息*/
double TotalInterest;
/*还款总额*/
double ReimbursementAmount;
/*年利率*/
double apr;
struct LoanInfo * next;
};
void CalcShow(struct LoanInfo * cur, struct LoanInfo * hd,
struct LoanInfo * prv);
int main(void)
{
int temp;
struct LoanInfo * head = NULL;
struct LoanInfo * prev, * current;
current = (struct LoanInfo *)malloc(sizeof(struct LoanInfo));
if (NULL == head)
{
head = current;
}
else
{
prev-next = current;
}/*End of if (NULL == head)*/
puts("请输入姓名");
gets(current-name);
fflush(stdin);
puts("请输入贷款数额(单位:万元)");
scanf("%lf", ¤t-LoanAmount);
fflush(stdin);
puts("请输入贷款年限");
scanf("%lf", ¤t-LoanYear);
fflush(stdin);
printf("姓名:%s,贷款年限:%lf, 贷款数额%lf",
current-name, current-LoanYear, current-LoanAmount);
prev = current;
puts("请确认Y/N");
temp = getchar();
switch(toupper(temp))
{
case 'Y' : CalcShow(current, head, prev);
break;
case 'N' : free(current);
main();
break;
default : puts("输入错误");
free(current);
break;
}
return 0;
}
void CalcShow(struct LoanInfo * cur, struct LoanInfo * hd,
struct LoanInfo * prv)
{
char lcv_temp;
if (cur-LoanYear = 1)
cur-apr = APR1;
else if (cur-LoanYear = 3)
cur-apr = APR2;
else if (cur-LoanYear = 5)
cur-apr = APR3;
else
cur-apr = APR4;
/*End of if (year = 1)*/
cur-LoanAmount = 10000 * cur-LoanAmount;
cur-ReimbursementAmount = cur-LoanAmount * pow((1 + cur-apr), cur-LoanYear);
cur-MonthlyPayment = cur-ReimbursementAmount / (cur-LoanYear * RTP);
cur-TotalInterest = cur-ReimbursementAmount - cur-LoanAmount;
printf("姓名:%s 贷款年限:%.0lf\n"
"贷款数额:%.2lf 每月还款额:%.2lf\n"
"利息合计:%.2lf 还款总额:%.2lf\n",
cur-name, cur-LoanYear, cur-LoanAmount,
cur-MonthlyPayment, cur-TotalInterest, cur-ReimbursementAmount);
puts("是否继续计算Y/N");
lcv_temp = getchar();
switch(toupper(lcv_temp))
{
case 'Y' : free(cur);
main();
break;
case 'N' : free(cur);
exit(0);
default : puts("输入错误");
free(cur);
main();
break;
}
system("pause");
}
作业要求:编写一个银行贷款计算器。显示如下: Loan Amount:贷款金额(单位:澳元) Loan Term:贷款期
对方的大雾等丰富的肤色更丰硕果实我问他热管散热广东省的的噶三分阿凡达莪无法违法服务。
有关银行贷款还贷的c语言程序
你的错误实在太多了。看代码王的程序简洁易懂
#includestdio.h
#includemath.h
int main()
{
double z,k,x,monthPay,allMoney,temp=0;
int n,i;
printf("输入借款总额、贷款年限、年利率: ");
//贷款总和最好不要用int型的,int的最大值是32767,那你岂不是超了
scanf("%lf%d%lf",z,n,k);
//计算n年后要还的总的钱数 pow(x,y)是在头文件math.h中的函数计算x^y
allMoney = z*pow((1+k/12),12*n);
//式子∑x(1+k/12)^i (i=0,1,2,..,n*12-1)将x提出到前面计算 temp=∑(1+k/12)^i
for(i=0; i12*n; i++)
temp += pow((1+k/12),i);
//根据等式z(1+k/12)^(12*n) = ∑x(1+k/12)^i (i=0,1,2,..,n*12-1) 得x=allMoney/temp;
x = allMoney/temp;
printf("每月应还款:%lf", x);
}
关于贷款利息计算器的代码和算贷款利息的计算器的介绍本篇到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
还没有评论,来说两句吧...