944,172 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 2508
  • C++ RSS
Jul 12th, 2006
0

C++ Mortgage Calculations Help!!

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
lballans is offline Offline
2 posts
since Jul 2006
Jul 12th, 2006
0

Re: C++ Mortgage Calculations Help!!

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.
Moderator
Reputation Points: 572
Solved Threads: 115
Mentally Challenged Mod.
WolfPack is offline Offline
1,559 posts
since Jun 2005
Jul 13th, 2006
0

Re: C++ Mortgage Calculations Help!!

Thanks for your help! I will try what you posted.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
lballans is offline Offline
2 posts
since Jul 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Factory Design pattern implementation
Next Thread in C++ Forum Timeline: Ask a problem,about inheritance :)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC