#include#include int main() { int price; int area; int number; int year; float benefit; printf("请输入单价(元/平方):"); scanf("%d",&price); printf("请输入面积:"); scanf("%d",&area); printf("请输入按揭成数:"); scanf("%d",&number); printf("请输入按揭年数:"); scanf("%d",&year); printf("请输入当前基准年利率:"); scanf("%f",&benefit); printf("==========报告结果==========n"); float allFang; float first; float allDai; float allHuan; float lixi; float monthHuan; float mbenefit; int time; mbenefit=benefit/100/12; time=year*12; allFang=price*area; first=allFang*(10.0-number); allDai=allFang*number; monthHuan=(allDai*mbenefit*pow((1+mbenefit),time))/(pow((1+mbenefit),time)-1); allHuan=monthHuan*time; lixi=allHuan-allDai; printf("房款总额:%.2f元n",allFang); printf("首期付款:%.2f元n",first); printf("贷款总额:%.2f元n",allDai); printf("还款总额:%.2f元n",allHuan); printf("支付利息:%.2f元n",lixi); printf("月均还款:%.2f元n",monthHuan); return 0; }
设计代码与运算都不算太难,唯一的学习到的可能就是买房时贷款后的月均还款额的计算公式是:
[贷款本金x月利率x(1+月利率)^ 还款月数]/[(1+月利率)^还款月数)-1]
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)