fork(2) download
  1. <?php
  2.  
  3.  
  4. function calculatePayments($credit, $percent, $service, $monthly, $paymentTotal) {
  5.  
  6. for ($month = 1; $month <= 20; $month ++) {
  7.  
  8. $compulsoryPayment = ( $credit * $percent ) + $service;
  9.  
  10. if ($compulsoryPayment > $monthly) {
  11. $credit = $compulsoryPayment - $monthly;
  12. $paymentTotal = $paymentTotal + $monthly;
  13. }
  14.  
  15. elseif ($compulsoryPayment < $monthly) {
  16. $credit = $credit - $credit;
  17. $paymentTotal = $paymentTotal + $compulsoryPayment;
  18. break;
  19. }
  20. }
  21. return $paymentTotal;
  22. }
  23.  
  24. $alfaBankTotal = calculatePayments(39999, 1.04, 500, 5000, 0);
  25. $privatBankTotal = calculatePayments(39999, 1.03, 1000, 5000, 0);
  26. $homeCreditTotal = calculatePayments(39999, 1.02, 0, 5000, 0) + 7777;
  27.  
  28. echo "AlfaBank = $alfaBankTotal\n";
  29. echo "PrivatBank = $privatBankTotal\n";
  30. echo "HomeCreditBank = $homeCreditTotal\n";
  31.  
  32. ?>
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
AlfaBank = 56423.563121625
PrivatBank = 61268.718210807
HomeCreditBank = 51806.365496746