C++ Mortgage Calculations Help!!

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jul 2006
Posts: 2
Reputation: lballans is an unknown quantity at this point 
Solved Threads: 0
lballans lballans is offline Offline
Newbie Poster

C++ Mortgage Calculations Help!!

 
0
  #1
Jul 12th, 2006
Hi All,

I'm new to C++ and I have a C++ mortgage assignment due where a user inputs there mortgage amount, interest rate, and term of the loan and the program should give the user there monthly payment and also ask the user if they want to quit or enter a new amount. However, I've been working on this for two days now but I'm having some trouble with my formula everything is compiling but when the user enters there information there monthly payment result is coming out with 1.#INF. I don't know where I'm going wrong so here is a copy of what I have. Any help will be appreciated.

 
//Lakesha Conaler
//Week 3 Individual Assignment
#include<math.h>
#include<iostream>
usingnamespace std;
int main ()
{
int l = 0; //amount of loan
double i = 0; //interest rate
int y = 0; // loan term
float j = i/(12.0 * 100.0); //Calculates the Interest
int m =y*12; //Number of months
int quit = 1; // decides if user wants to quit
double loanpay; //outputs users loan amount
do
{
cout << "Input the total loan amount:\n";
cin >> l;
cout << "Input your interest rate:\n";
cin >> i;
cout << "Input your number of years:\n";
cin >> y;

j = i/(12.0*100.0);
 
loanpay = (l * i) / (1 - pow((1+i),-m));

cout << "Your monthly payment is: $"<< loanpay<<"\n";
cout << "To Enter a new Loan Amount press 1 or 2 to quit\n";
cin >> quit;
} while (quit==1);
return 0;
}
Last edited by Dave Sinkula; Jul 12th, 2006 at 7:37 pm.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: C++ Mortgage Calculations Help!!

 
0
  #2
Jul 12th, 2006
You are not doing the calculation for m after getting the value for y from the user.Put
m =y*12; after the cin >> y; part.
バルサミコ酢やっぱいらへんで
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 2
Reputation: lballans is an unknown quantity at this point 
Solved Threads: 0
lballans lballans is offline Offline
Newbie Poster

Re: C++ Mortgage Calculations Help!!

 
0
  #3
Jul 13th, 2006
Thanks for your help! I will try what you posted.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC