|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
#include<windows.h>
#include<math.h>
int main()
{
int years , percent ; //按揭年数、按揭成数
float price , area , rate , mon; // 单价(元/平方)、面积 、年利率 、月利率
float total , down_payment ;//房款总额、首付款
float total_loan , total_repay ;//贷款总额、还款总额
double avr_repay ,interest; //利息 // 月还款
printf("请输入单价(元/平方):");
scanf("%f", &price);
printf("请输入房屋面积:");
scanf("%f", &area);
printf("请输入按揭成数:");
scanf("%d", &percent);
fflush(stdin);
printf("请输入按揭年数:");
scanf("%d", &years);
printf("请输入当年基准年利率:");
scanf("%f", &rate);
total = price*area;//房款总额
mon = years/100/12; //月利率
years = years*12;
down_payment = total*(1-(float)percent/10);//首期付款
total_loan = total-down_payment;//贷款总额
avr_repay = total_loan*mon*pow((1 + mon), years) / (pow((1 + mon), years) - 1); //月均还款
interest = avr_repay*years;//支付利息
total_repay = interest + total_loan;//还款总额
printf("=====计算结果=====\n");
printf("房款总额:%.2f\n",total);
printf("首期付款:%.2f\n",down_payment);
printf("贷款总额:%.2f\n",total_loan);
printf("还款总额:%.2f\n",total_repay);
printf("支付利息:%.2f\n",interest);
printf("月均还款:%.2f\n",avr_repay);
system("pause");
return 0;
} |
-
代码结果
|