GIDForums  

Go Back   GIDForums > Computer Programming Forums > CPP / C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 08-Dec-2007, 17:18
martinez1112 martinez1112 is offline
New Member
 
Join Date: Dec 2007
Posts: 2
martinez1112 is on a distinguished road

Incorrect answed on code mortgage


Hello,

I think that I have done my code correctly but I'm having problem when I run the code the answerd is suppost to be $1167.15 and I'm getting $11500

I'm thinking that the problem is with the formula but I don't know where.

Here is my code

CPP / C++ / C Code:


/********************************************************************
 Program Name: martinez_week2.cpp
        
 Student Name: Gabriel Martinez-Mercado

 Date: 12/07/07

 Learning Team: LT B

 Course: PRG/410

 Program Description: Write a procedural C++ program which
					  calculates the monthly payments   on
					  a fully amortized loan amount of $200,000,
					  for a term of 30 years, and an interest
					  rate of 5.75%.  
**********************************************************************/
#include "stdafx.h"
#include <cmath>
#include <iostream>
using namespace std;

int main()
{
  int L = 200000; //amount of the loan
  double i = .0575; // the losn interest rate
  int y = 30; //years of the loan
  int t = y*12; //loan term in months
  double mPayment; //variable for ouputting the payment

  mPayment = (L * i) / (1 - pow((1+i),-t)); //Formula to figure mortgage payment amount

  cout<< "Your Monthly Payment Amount is: $"<< mPayment; //prints out montyly payment amount
  cout<< "\n";
  system("PAUSE");
  return 0;
}
  #2  
Old 08-Dec-2007, 20:17
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,627
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Incorrect answed on code mortgage


Quote:
Originally Posted by martinez1112
I'm thinking that the problem is with the formula...
That would be my guess.
CPP / C++ / C Code:

  double i = .0575; 
.
.
.
  mPayment = (L * i) / (1 - pow((1+i),-t));


I'm thinking that the interest rate is quoted as 5.75% per year. The formula applies that amount of interest each month for 360 months. Use the monthly interest rate.

In simplified form, they usually assume that the monthly interest rate is equal to the yearly interest rate divided by 12. Try i = 0.0575/12.0;


Regards,

Dave
  #3  
Old 08-Dec-2007, 20:25
martinez1112 martinez1112 is offline
New Member
 
Join Date: Dec 2007
Posts: 2
martinez1112 is on a distinguished road

Re: Incorrect answed on code mortgage


Thks Dave,

That was my error I was thinking just in one time insted of the 12 months
 
 

Recent GIDBlogNARMY by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to sort random access file? wmmccoy0910 C Programming Language 12 04-Sep-2006 03:40
Java GUI Mortgage Program Harryt123 Java Forum 0 21-Jul-2006 16:57
Here it is again! 35% - 40% off For Life! my-e-space Web Hosting Advertisements & Offers 0 20-Apr-2006 14:48
User defined headers davis Miscellaneous Programming Forum 6 16-Feb-2006 18:40
Problem with int mixed with char,... leitz CPP / C++ Forum 17 07-Dec-2004 20:56

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 04:35.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.