利率计算器C ++

时间:2015-01-14 21:58:13

标签: c++

我试图制作一个利率计算器。我一直在这些方面得到这个

rate >> Annualr / 12.0;


payment >> (rate * pow((1 + rate), paymentnumber) / pow((1 + rate), paymentnumber) - 1)*loan;

大方程应该计算贷款产生的利息金额

"非法,左操作数类型为' double'"
"非法,右操作数类型为' double'"



#include
<iostream>
  #include
  <string>
    #include
    <cmath>
      #include
      <iomanip>
        using namespace std; void main() { double Annualr = 0.0, loan = 0.0, payment = 0.0, rate = 0.0; int paymentnumber = 0; string fullname; cout
        << "Enter the full loan ammount: "; cin>> loan; cout
          << "Enter the Annual interest rate: "; cin>> Annualr; cout
            << "How many payments have you made? "; cin>> paymentnumber; rate >> Annualr / 12; payment >> (rate * pow((1 + rate), paymentnumber) / pow((1 + rate), paymentnumber) - 1)*loan; cout
              << "Loan Ammount: " << loan << endl; cout << "Monthly Interest Rate: " << rate << endl; cout <<
              "Number of Payments: " << paymentnumber << endl; cout << "Monthly Payment: " << payment << endl; cout << "Ammount paied back: " << payment * paymentnumber << endl; cout << "Interestt paied: " << loan - (payment * paymentnumber) << endl; system( "pause"); }
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:3)

按照下面的行修改代码中的拼写错误,它应该可以正常工作。

rate = Annualr / 12;
payment = (rate * pow((1 + rate), paymentnumber) / pow((1 + rate), paymentnumber) - 1)*loan;

答案 1 :(得分:0)

看起来您正在尝试为double类型的变量赋值,但出于任何原因错误地放置了operator>>

rate = Annualr / 12;
payment = (rate * pow((1 + rate), paymentnumber) / pow((1 + rate), paymentnumber) - 1)*loan;