fork download
  1. <?php
  2. $creditSum = 39999;
  3. $monthlyPayment = 5000;
  4.  
  5. function countCredit($persent, $servicePayment, $startPrice){
  6. $creditSum = 39999;
  7. $monthlyPayment = 5000;
  8. $creditBalance = $creditSum + $startPrice;
  9. for ($month = 1; $month <= 20; $month ++) {
  10.  
  11. $creditBalance = ( $creditBalance * $percent ) + $servicePayment - $monthlyPayment;
  12. $paymentTotal = $paymentTotal + $monthlyPayment;
  13.  
  14. if ($creditBalance < 4000) {
  15. $paymentTotal = $paymentTotal + $creditBalance;
  16. break;
  17. }
  18. }
  19. return $paymentTotal;
  20. };
  21.  
  22.  
  23. $homoCreditTotal = countCredit(4,500,0);
  24. $softbankTotal = countCredit(3,1000,0);
  25. $strawberryBankTotal = countCredit(2,0,7777);
  26. echo "{$homoCreditTotal}\n {$softbankTotal}\n {$strawberryBankTotal}";
Success #stdin #stdout #stderr 0.02s 24448KB
stdin
Standard input is empty
stdout
500
 1000
 0
stderr
PHP Notice:  Undefined variable: percent in /home/Oy7qVS/prog.php on line 11
PHP Notice:  Undefined variable: paymentTotal in /home/Oy7qVS/prog.php on line 12
PHP Notice:  Undefined variable: percent in /home/Oy7qVS/prog.php on line 11
PHP Notice:  Undefined variable: paymentTotal in /home/Oy7qVS/prog.php on line 12
PHP Notice:  Undefined variable: percent in /home/Oy7qVS/prog.php on line 11
PHP Notice:  Undefined variable: paymentTotal in /home/Oy7qVS/prog.php on line 12