fork download
  1. <?php
  2.  
  3.  
  4. function getBalance($percent, $servicePayment, $creditBalance, $paymentTotal) {
  5. $monthlyPayment = 5000;
  6. for ($month = 1; $month <= 20; $month++) {
  7. $creditBalance = ($creditBalance * $percent) + $servicePayment;
  8. if ($creditBalance < 5000) {
  9. $monthlyPayment = $creditBalance;
  10. $paymentTotal = ($paymentTotal + $monthlyPayment);
  11. $creditBalance = ($creditBalance - $monthlyPayment);
  12. break;
  13. } elseif ($creditBalance > 5000) {
  14. $paymentTotal = ($paymentTotal + $monthlyPayment);
  15. $creditBalance = ($creditBalance - $monthlyPayment);
  16. }
  17. }
  18. return $paymentTotal;
  19. }
  20.  
  21. $homoCreditTotal = getBalance(1.04, 500, 39999, 0);
  22. $softBank = getBalance(1.03, 1000, 39999, 0);
  23. $strawberryBank = getBalance(1.03, 0, 47776, 0);
  24.  
  25. echo "homocredit = $homoCreditTotal\n";
  26. echo "softbank = $softBank\n";
  27. echo "strawberrybank = $strawberryBank\n";
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
homocredit = 56423.563121625
softbank = 61268.718210807
strawberrybank = 57157.004322267