By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,680 Members | 2,139 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,680 IT Pros & Developers. It's quick & easy.

Mortgage Monthly Payment

P: 10
Hi I am new here in this forum: I am writing a C++ program to calculate a Montly Mortgage Payment where the loan amount is 200,000.00 with a 5.75% interest rate with a term of 30 years. My program compiles fine with no errors but my calculation is not working correctly, any suggestions would be great as this assignment is due on Monday:
//************************************************** *****
//Program: Calculations Payments
//Purpose: To calculate a monthly payment over
//Programmer: Cameron Faldeti
//Date: 10/23/06
//School: University of Phoenix
//Class: POS 440: Introduction To C++
//Instructor: John Williams
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
const double LoanAmount = 200000.00; //Named constant for total loan amount
const int term = 30; //Term in years, 30 years, for 12 months in a year
const double InterestRate = 0.0575; //Named constant for the interest rate in a percentage used in the loan process.
int main()
{
//variable declarations
double MortgageMonthlyPayment;
cout << fixed << showpoint;
cout << setprecision(2);
cout << "This program computes a mortgage monthly payment for over a 30 year time period." << endl; //Letting the user know the purpose of the program
MortgageMonthlyPayment = LoanAmount*((InterestRate/12)*(1+(InterestRate/12))*360*(term*12))/((1+(InterestRate/12))*360*(term*12)-1); //Calculates the monthly mortgage payment
cout << "Your Mortgage monthly payment is: $ " << MortgageMonthlyPayment << endl;
return 0;//ends the program
}
Oct 26 '06 #1
Share this Question
Share on Google+
3 Replies


Banfa
Expert Mod 5K+
P: 8,916
What is the actual value you code produces and the value you expected it to produce.

I suspect this line

MortgageMonthlyPayment = LoanAmount*((InterestRate/12)*(1+(InterestRate/12))*360*(term*12))/((1+(InterestRate/12))*360*(term*12)-1);

is wrong, how did you come by it? I think you will be needing to use the pow(...) function somewhere in this equation.
Oct 26 '06 #2

P: 10
What is the actual value you code produces and the value you expected it to produce.

I suspect this line

MortgageMonthlyPayment = LoanAmount*((InterestRate/12)*(1+(InterestRate/12))*360*(term*12))/((1+(InterestRate/12))*360*(term*12)-1);

is wrong, how did you come by it? I think you will be needing to use the pow(...) function somewhere in this equation.
The expected result should be $1,167.15.

I came by that line realizing that 30*12 is 360. I am reading about the Pow() function, but I do not understand how to set it up.

For right now when I do run my program I am getting $958.34
Oct 26 '06 #3

Banfa
Expert Mod 5K+
P: 8,916
Where did you get that equation from?
Oct 27 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.