有关银行贷款还贷的c语言程序

Python020

有关银行贷款还贷的c语言程序,第1张

你的错误实在太多了。看代码王的程序简洁易懂#include<stdio.h>#include<math.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^yallMoney = z*pow((1+k/12),12*n) //式子∑x(1+k/12)^i (i=0,1,2,..,n*12-1)将x提出到前面计算 temp=∑(1+k/12)^ifor(i=0i<12*ni++)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)}

/*

* main.c

*

* Created on: 2011-6-8

* Author: icelights

*/

#include <stdio.h>

#include <stdlib.h>

#include <ctype.h>

#include <math.h>

#define APR10.0747/*<1年(含1年)年利率*/

#define APR20.0756/*1-3年(含3年)年利率*/

#define APR30.0774/*3-5年(含5年)年利率*/

#define APR40.0783/*5年以上年利率*/

#define A_TO_M 1/12 /*月利率 = 年利率 / 12*/

#define RTP 12/*Reimbursement total periods还款总期数 =年限*12*/

#define LENGTH 80

struct LoanInfo

{

/*姓名*/

char name[LENGTH]

/*贷款总额*/

doubleLoanAmount

/*贷款年限*/

doubleLoanYear

/*月付*/

doubleMonthlyPayment

/*总利息*/

doubleTotalInterest

/*还款总额*/

doubleReimbursementAmount

/*年利率*/

doubleapr

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")

}

房贷计算器如何使用:

1. 百度搜索”房贷计算器“,接着页面会出现一个计算器

2. 两种计算方式,可以选择按贷款额度计算,也可以按照面积计算,咱们先按贷款额度计算,

3. 输入贷款金额,贷款期限,点击”计算“,

4. 现在下方就出现了你的还贷金额

5. 然后呢,咱们按照面积再计算一遍,就当再检测一遍,呵呵,输入"平米单价”和“面积”,点击“计算”,

6. 现在下方就出现了你所要的结果,和刚才的结果对比一下是否正确

7. 如果担心自己计算的不准确,还可以点击“重置”重新输入数值进行计算

房贷还款方式的计算公式:

一、等额本息计算公式:计算原则:银行从每月月供款中,先收剩余本金利息,后收本金利息在月供款中的比例中随剩余本金的减少而降低,本金在月供款中的比例因增加而升高,但月供总额保持不变。

二 、等额本金计算公式:每月还款额=每月本金+每月本息,每月本金=本金/还款月数。

每月本息=(本金-累计还款总额)X月利率,计算原则:每月归还的本金额始终不变,利息会随剩余本金的减少而减少。

房贷方式:

个人住房委托贷款全称是个人住房担保委托贷款,它是指住房资金管理中心运用住房公积金委托商业性银行发放的个人住房贷款。住房公积金贷款是政策性的个人住房贷款,一方面是它的利率低另一方面主要是为中低收入的公积金缴存职工提供这种贷款。