当前位置: 代码迷 >> 综合 >> 钱升钱
  详细解决方案

钱升钱

热度:0   发布时间:2024-01-15 09:05:49.0

/* * Copyright (c) 2012, 烟台大学计算机学院

* All rights reserved.

* 作 者: 张浩

* 完成日期:2012 年 10月 22日

* 版 本 号:v1.0 *

* 输入描述:

* 问题描述:

* 程序输出

* 问题分析:

* 算法设计:    

#include<cmath>   

namespace std;   

int main( )   

{   

    double principal,rate,payPerYear,numYears,payment,number,denom,b,e;    

    cout << "输入本金:";   

    cin >> principal;   

    cout << "输入利率: ";   

    cin >> rate;   

    cout << "输入每年还款次数 ";   

    cin >> payPerYear;   

    cout << "输入还款年数: ";   

    cin >> numYears;   

    number = rate * principal / payPerYear;   

    e = -(payPerYear * numYears );   

    b = (rate / payPerYear )+1;   

    denom = 1 - pow(b,e);     

    payment = number / denom;   

    cout << "每次需要还款: " << payment<<endl;   

    return 0;   

} 

#include<iostream>  
#include<cmath>  
using namespace std;  
int main( )  
{  double principal,rate,payPerYear,numYears,payment,number,denom,b,e;   cout << "输入本金:";  cin >> principal;  cout << "输入利率: ";  cin >> rate;  cout << "输入每年还款次数 ";  cin >> payPerYear;  cout << "输入还款年数: ";  cin >> numYears;  number = rate * principal / payPerYear;  e = -(payPerYear * numYears );  b = (rate / payPerYear )+1;  denom = 1 - pow(b,e);    payment = number / denom;  cout << "每次需要还款: " << payment<<endl;  return 0;  
}

 

运行结果: 

*运行结果:

心得体会:   一直在草稿箱呢,现在才发表

  相关解决方案