|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
#include <math.h>
int main()
{
double price, area, percent, rate, Total, Fisrt_Payment, Total_Loan, Total_Repayment, Interest_for_payment, Payment_per_month, pricial, rate_per_month;
int year;
printf("请输入单价(元/平方):");
scanf("%f",&price);
printf("请输入面积:");
scanf("%f",&area);
printf("请输入按揭成数:");
scanf("%f",&percent);
printf("请输入按揭年数:");
scanf("%d",&year);
printf("请输入当前基准年利率:");
scanf("%f",&rate);
rate_per_month = rate / 12 / 100; //月利率
Total = price * area; // 房屋总价
pricial= Total * (percent/10); //还款本金
Payment_per_month = pricial * (rate_per_month*pow((1+rate_per_month), year*12)) / ((pow(1+ rate_per_month), year*12) -1.0); // 月还款额
Total_Repayment = (year * 12) * Payment_per_month; // 还款总额
Fisrt_Payment = Total - Total_Loan; //首付
Total_Repayment = Payment_per_month* year *12; //
Total_Loan = pricial; // 贷款总额
Interest_for_payment = Total_Repayment - Total_Loan; //支付利息
printf("========报告结果========\n");
printf("房款总额:%.2f\n",Total);
printf("首期付款: %.2f\n",Fisrt_Payment);
printf("贷款总额: %.2f\n",Total_Loan);
printf("还款总额: %.2f\n",Total_Repayment);
printf("支付利息:%.2f\n",Interest_for_payment);
printf("月均还款: %.2f\n",Payment_per_month);
return 0;
}
调试的时候,说Payment_per_month = pricial * (rate_per_month*pow((1+rate_per_month), year*12)) / ((pow(1+ rate_per_month), year*12) -1); 语句错误,错误内容如下:
[Error] too few arguments to function 'pow'
pow函数的调用是需要两个参数的, 注意一下 “月还款额” 那一行后面的pow括号的位置
|
|