fork(1) download
  1. <?php
  2.  
  3.  
  4. function calculationPayment($percent, $commission, $payOpeningAccount, $payout, $creditSum){
  5. $amountPayment = 0;
  6. $amountCredit = $creditSum + $payOpeningAccount;
  7. for($month = 0; $amountCredit != 0; $month++){
  8. $amountCredit += $percent*$amountCredit + $commission;
  9. if ($amountCredit < $payout){
  10. $amountPayment += $amountCredit;
  11. $amountCredit -= $amountCredit;
  12. }else{
  13. $amountPayment += $payout;
  14. $amountCredit -= $payout;
  15. }
  16. }
  17. $return = array (
  18. 'month' => $month,
  19. 'amountPayment' => $amountPayment
  20. );
  21.  
  22. return $return;
  23. }
  24.  
  25. $creditSum = 39999;
  26. $payout = 5000;
  27.  
  28. $homoCreditTotal = calculationPayment(0.04, 500, 0, $payout, $creditSum);
  29. $softbankTotal = calculationPayment(0.03, 1000, 0, $payout, $creditSum);
  30. $strawberryBankTotal = calculationPayment(0.02, 0, 7777, $payout, $creditSum);
  31.  
  32. echo "homoCredit Сумма выплат: {$homoCreditTotal['amountPayment']} Срок в месяцах: {$homoCreditTotal['month']}\n";
  33. echo "softbank: {$softbankTotal['amountPayment']} Срок в месяцах: {$softbankTotal['month']}\n";
  34. echo "strawberryBank: {$strawberryBankTotal['amountPayment']} Срок в месяцах: {$strawberryBankTotal['month']}\n";
  35. ?>
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
homoCredit Сумма выплат: 56423.563121625 Срок в месяцах: 12
softbank: 61268.718210807 Срок в месяцах: 13
strawberryBank: 53559.8738592 Срок в месяцах: 11