fork download
  1. <?php
  2.  
  3. function bank ($sumCredit, $percent, $gross, $pay, $onePay){
  4. $ending = 0;
  5. for ($mounth = 1; $mounth <= 25; $mounth ++){
  6. if ($sumCredit > $pay){
  7. $sumCredit = ($sumCredit * $percent) + $gross - $pay;
  8. }
  9. else{
  10. $pay = $sumCredit;
  11. $sumCredit = 0;
  12. }
  13. $ending = $ending + $pay + $gross;
  14. }
  15. return $ending;
  16. }
  17.  
  18. $sumCredit = 39999;
  19. $pay = 5000;
  20. $homoCreditTotal = bank ($sumCredit, 1.04, 500, $pay, 0);
  21. $softBankTotal = bank ($sumCredit, 1.03, 1000, $pay, 0);
  22. $strawBerryBankTotal = bankSBB ($sumCredit, 1.02, 0, $pay, 7777);
  23.  
  24. function bankSBB ($sumCredit, $percent, $gross, $pay, $onePay){
  25. $ending = 0;
  26. $sumCreditBank = $sumCredit + $onePay;
  27. for ($mounth = 1; $mounth <= 25; $mounth ++){
  28. if ($sumCreditBank > $pay){
  29. $sumCreditBank = ($sumCreditBank * $percent) + $gross - $pay;
  30. }
  31. else{
  32. $pay = $sumCreditBank;
  33. $sumCreditBank = 0;
  34. }
  35. $ending = $ending + $pay + $gross;
  36. }
  37. return $ending;
  38. }
  39.  
  40.  
  41. echo "HomoCredit Bank: {$homoCreditTotal} рублей \n";
  42. echo "Soft Bank: {$softBankTotal} рублей \n";
  43. echo "StrawBerry Bank: {$strawBerryBankTotal} рублей \n";
  44.  
  45. /*
  46. $sumCredit - сумма кредита
  47. $percent - проценты
  48. $gross - комиссия
  49. $pay - платеж
  50. $onePay - доп платеж банка StrawBerry
  51. */
  52.  
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
HomoCredit Bank: 68388.041463101 рублей 
Soft Bank: 84136.787831848 рублей 
StrawBerry Bank: 53490.07241098 рублей