计算还款额度

来源:互联网 发布:网络切换器连不上网 编辑:程序博客网 时间:2024/04/29 02:26
 /*   * Copyright (c) 2011, 烟台大学计算机学院   * All rights reserved.   * 文件名称:test.cpp   * 作    者:  袁静   * 完成日期:2012 年 10月 20日   * 版 本 号:v1.0   *   * 输入描述:无   * 问题描述:编程序用来计算贷款的定期还款额度,priincipal(本金),payperYear(每年偿还的次数),numYears(贷款年限),rate(利率)  * 程序输出:   * 问题分析:略  * 算法设计:略   */ #include<iostream>   #include<cmath>   using namespace std;  int main( )  {      double principal;  本金      double rate; //利率      double payPerYear; //每年偿还的次数       double numYears; //偿还的年限       double payment; //       double number, denom; //      double b,e;       cout << "please enter principal:";      cin >> principal;      cout << "please enter rate: ";      cin >> rate;      cout << "please enter payperYear";      cin >> payPerYear;      cout << "please enter numYears: ";      cin >> numYears;      number = rate * principal / payPerYear;      e = -(payPerYear * numYears );      b = (rate / payPerYear )+1;      denom = 1 - pow(b,e);         payment = number / denom;      cout << "Payment is " << payment<<endl;      return 0;  }