Monthly Interest

Hey!! New to the forum and C++ I'm doing this assignment right now and I thought I was doing it correctly but my output is totally off and the interest calculations are off. I thought I typed it in correctly but I'm not sure why the calculations are so off and help is much appreciated. Thanks!

[code]
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()


{

//1. Declare Variables
double loanAmount;
double yearIntRate;
double monIntRate;
double noOfPayments;
double payment;
double amtPaidBack;
double intPaid;



//2. Assign the Input

monIntRate = yearIntRate / 12;

cout << "Please enter the Loan Amount: ";
cin >> loanAmount;

cout << "Please enter the Monthly Interest Rate: ";
cin >> monIntRate;

cout << "Please enter the Number of Payments: ";
cin >> noOfPayments;

cout << fixed << setprecision (2);



//3. Do A Calculation
//monIntRate = yearIntRate / 12;

payment = (monIntRate * pow(monIntRate + 1, noOfPayments)) / (pow(monIntRate + 1, noOfPayments) - 1) * loanAmount;

amtPaidBack = payment * noOfPayments;

intPaid= amtPaidBack - loanAmount;






//4. Display the Results

cout << "Loan Amount: " << loanAmount << endl;
cout << "Monthly Interest Rate: " << monIntRate << endl;
cout << "Number of Payments: " << noOfPayments << endl;
cout << "Monthly Payment: " << payment << endl;
cout << "Amount Paid Back: " << amtPaidBack << endl;
cout << "Interest Paid: " << intPaid << endl;

return 0;

}
[code]

/*Please enter the Loan Amount: 1000
Please enter the Monthly Interest Rate: .05
Please enter the Number of Payments: 10
Loan Amount: 1000.00
Monthly Interest Rate: 0.05
Number of Payments: 10.00
Monthly Payment: 129.50
Amount Paid Back: 1295.05
Interest Paid: 295.05
*/
Last edited on
Whats wrong with it?
The monthly payment calculation is off and I cant figure out why it is. the monthly payment shows 129.50 off of a .05 interest rate which is not right but the calculation looks correct
.
Last edited on
If it helps, with a loan amount of $1000, 5% annual interest, and 10 equal monthly payments, your program spits out the correct numbers (monthly payment = $102.31), when 0.004167 is input as the monthly interest rate.

0.004167 = 0.05/12 (0.05 = "5 percent", and since it's 5% per year, dividing by 12 gives you the monthly interest rate of 0.004167)

Not only did $102.31 strike me intuitively as being about right, but I actually ran the numbers through my HP 12C calculator - cutting edge Reagan-era technology, which is a mainstay of the financial community to this day - and HP's finest confirms the amount as being correct.

Last edited on
You guys are right it is correct I dont know what I was thinking thanks!
Topic archived. No new replies allowed.