C++ Consule Program
Posted on 2013-06-24
I am writing this small test application to calculate loan interest rates. When I compile that application I am getting the error message below for this line of code:
Monthly_Payment = Rate * (1 + Rate)^N / ((1+Rate)^N -1) * Loan_Amount;
error C2297: '^' : illegal, right operand has type 'double'
All variables are of the type "double" so I do not see where this should be an issue. Also when I comment out this code, and execute the application, it is supposed to ask for the interest input and then calculate the results and display them. However after you enter the requested information, the window disappears instead of displaying the results in the report format.
Below is that block of code:
// Display results
cout << "\n--------------------"
<< fixed << showpoint << setprecision(2)
<< "\nloan_amount: " << Loan_Amount
<< "\nAnnual Interest Rate: " << setw(8) << Rate
<< "\nNumber of Payments: " << setw(8) << N
<< "\nMonthly_Payment: $" << setw(8) << Monthly_Payment
<< "\nAmount Paid Back: $" << setw(8) << Amount_Total
<< "\nInterest Paid: $" << setw(8) << Interest_Paid
<< endl << endl;