4
I have to do this little work in PHP structured below, but I have a problem there in the formula of interest rate, I didn’t understand how to apply, I did so:
/* Calcula os Juros
------------------------------------------------------------- */
function juros($dados){
$r = (($dados['preco'] * (1 + $dados['txjuros']) ^ $dados['parcelas'] ) * $dados['txjuros']) / ((1 + $dados['txjuros']) ^ $dados['parcelas'] - 1);
return $r;
}
The correct formula is in the image below:
Second attempt:
I made an algorithm with a different formula, but then the interest was fixed, regardless of the amount of installments.
The value of interest should rise by as much % over the value of each instalment.
If I put 4 installments is the same interest value that if I put 10 installments, then it is wrong so, should set value x interest for first installment and value y interest for second installment.
Someone can help me by analyzing my code, the error must be in the logic of applying the formula granted by the teacher.
PHP code:
André, limit yourself to one topic per question. Even if you have the knowledge in financial mathematics, your question is outside the context of the site.
– gmsantos
Buddy, tell me what you have to calculate so I can tell you what expression you have to use...
– HiHello
Because you put the expression you are using, but you did not put what the goal is. So there is no way we can say if it is correct or not...
– HiHello
The application will never work because there is a division of the AMOUNT by the DISCOUNT
– user33551