Advertisement
fvasconcelos

Divergência em valores decimais

Jun 26th, 2020
1,219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function jurosComp(capital, taxa, tempo){
  2.     for(let i = 0; i < tempo; i++){
  3.         capital = capital * (taxa/100) + capital;
  4.     }
  5.     return console.log('Juros compostos: R$', capital.toFixed(2).replace('.', ','));
  6. }
  7.  
  8. function jurosSimp(capital, taxa, tempo){
  9.     let rendimento = capital * (taxa/100);
  10.     for(let i = 0; i < tempo; i++){
  11.         capital = capital + rendimento;
  12.     }
  13.     return console.log('Juros simples: R$', capital.toFixed(2).replace('.', ','));
  14. }
  15.  
  16. jurosComp(1423.65, 3.76, 13);
  17. jurosSimp(1423.65, 3.76, 13);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement