I am having trouble getting this to work. I cannot figure out if its a syntax error or what.
Here is the original problem:
Payment = Rate * (1 + Rate)^N / ((1+Rate)^N -1) * Loan
Rate is the monthly interest rate. Rates for loans are
expressed as annual percentage rate (e.g., 18.0% APR).
N is the number of payments.
Loan is the amount of the loan.
Write a program with an interactive console dialog to
accept input from the keyboard. Then calculate the
monthly payment, amount paid back, and the interest paid.
Display a formatted report similar to:
Loan Amount: $ 10000.00
Annual Interest Rate: 12.00%
Number of Payments: 36
Monthly Payment: $ 332.14
Amount Paid Back: $ 11957.15
Interest Paid: $ 1957.15
Here is my code so far.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <stdlib.h>
using namespace std;
int main()
{
//define variables
double loanamount;
double rate;
double payments;
double monthly;
double payback;
double intrest;
double a;
double b;
double c;
//inputs
cout<<"Enter Loan Amount: ";
cin>>loanamount;
cout<<"Enter Intrest Rate: ";
cin>>rate;
cout<<"Enter Number of Payments: ";
cin>>payments;
system("CLS");
//define formula
a = rate * (pow((1+rate),payments));
b = (pow((1+rate),(payments-1)*loanamount));
monthly = a/b;
//formula
//outputs
cout<<"Loan Amount: "<<loanamount<<endl;
cout<<"Anual Intrest Rate: "<<rate<<endl;
cout<<"Number Of payments: "<<payments<<endl;
cout<<"Monthly Payment: "<<monthly<<endl;
cout<<a<<endl;
cout<<b<<endl;
cout<<c;
return 0;
}
|
The reason there are cout's for A,B,C is just for testing trying to get the numbers to come out right. So far i cannot figure out how to get the pow() function to work correctly. Any help is appreciated! Thanks!