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.
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.