fork(2) download
  1. <?php
  2.  
  3. function totalPay($monthPay, $tax, $creditSum, $bankPercent, $bankName, $oneTimeTax) {
  4. for ($month = 1; $month <= 20; $month++) {
  5. $creditSum = ($creditSum * $bankPercent) + $tax - $monthPay;
  6.  
  7.  
  8.  
  9. $total = $total + $monthPay;
  10.  
  11.  
  12.  
  13. if ($creditSum < 0) {
  14. $monthPay = $creditSum;
  15. $total = $total + $monthPay + $oneTimeTax;
  16. $creditSum = $creditSum - $monthPay;
  17. $month = $month + 1;
  18. echo "Анон платит {$month} месяцев. Заплатит {$total} банку {$bankName}.\n";
  19. break;
  20. }
  21. }
  22. echo "\n\n";
  23. }
  24.  
  25.  
  26. $homoCredit = totalPay(5000, 500, 39999, 1.04, 'HOMOCREDIT', 0);
  27. $softBank = totalPay(5000, 1000, 39999, 1.03, 'SOFTBANK', 0);
  28. $strawberryBank = totalPay(5000, 0, 39999, 1.02, 'STRAWBERRYBANK', 7777);
  29.  
  30.  
  31. echo "{$homoCredit}\n";
  32. echo "{$softBank}\n";
  33. echo "{$strawberryBank}\n";
Success #stdin #stdout #stderr 0.02s 24448KB
stdin
Standard input is empty
stdout
Анон платит 13 месяцев. Заплатит 56423.563121625 банку HOMOCREDIT.


Анон платит 14 месяцев. Заплатит 61268.718210807 банку SOFTBANK.


Анон платит 10 месяцев. Заплатит 51806.365496746 банку STRAWBERRYBANK.





stderr
PHP Notice:  Undefined variable: total in /home/nz8lPL/prog.php on line 10
PHP Notice:  Undefined variable: total in /home/nz8lPL/prog.php on line 10
PHP Notice:  Undefined variable: total in /home/nz8lPL/prog.php on line 10