|
-
Jun 6th, 2011, 02:27 AM
#1
Thread Starter
Member
COding help, output is wrong
Code:
double getPaymentAmount(double interest, int numberOfMonths, double principal)
{
double getPaymentAmount;
getPaymentAmount = (powf((1+interest),numberOfMonths)/
(powf((1+interest),numberOfMonths)-1)
*principal*interest);
return getPaymentAmount;
}
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
double getLoanAmount(double interest, int numberOfMonths, double payment)
{
double getLoanAmount;
getLoanAmount = (powf((1+interest),numberOfMonths) - 1*payment)/
(interest*powf((1+interest),numberOfMonths));
return getLoanAmount;
}
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
int getNumberOfMonths(double interest, double payment, double principal)
{
int getNumberOfMonths;
getNumberOfMonths = (log(payment)-log(payment-(principal*interest))) /
(log(1+interest));
return getNumberOfMonths;
payment = (1 + i)^ months * principal * i
--------------------------------------------------------------------------------
(1 + i) months - 1
principal = (1 + i )^ months - 1 * payment
--------------------------------------------------------------------------------
i * (1 + i ) months
months = log( payment ) - log( payment - (principal * i ))
--------------------------------------------------------------------------------
log( 1 + i )
this is the regular formula. can someone tell me what im doing wrong here?
-
Jun 6th, 2011, 02:28 AM
#2
Thread Starter
Member
Re: COding help, output is wrong
--------------------- means divide it by
(1+i)^months
-------------- * principal * i
(1+i)^months -1
ect,,,
-
Jun 10th, 2011, 09:24 PM
#3
Re: COding help, output is wrong
What are the inputs and expected outputs? What are the actuals? Also this part of your formula doesn't make sense to me:
principal = (1 + i )^ months - 1 * payment
Why would you be multiplying the payment by 1? It's not going to do anything. Should it be:
principal = (1 + i )^(months - 1) * payment
??
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|