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


7777
stderr
PHP Notice:  Undefined variable: total in /home/aqfQeg/prog.php on line 7
PHP Notice:  Undefined variable: total in /home/aqfQeg/prog.php on line 7
PHP Notice:  Undefined variable: total in /home/aqfQeg/prog.php on line 7