<?php
function bank ($sumCredit, $percent, $gross, $pay, $onePay){
$ending = 0;
for ($mounth = 1; $mounth <= 25; $mounth ++){
if ($sumCredit > $pay){
$sumCredit = ($sumCredit * $percent) + $gross - $pay;
}
else{
$pay = $sumCredit;
$sumCredit = 0;
}
$ending = $ending + $pay + $gross;
}
return $ending;
}
$sumCredit = 39999;
$pay = 5000;
$homoCreditTotal = bank ($sumCredit, 1.04, 500, $pay, 0);
$softBankTotal = bank ($sumCredit, 1.03, 1000, $pay, 0);
$strawBerryBankTotal = bankSBB ($sumCredit, 1.02, 0, $pay, 7777);
function bankSBB ($sumCredit, $percent, $gross, $pay, $onePay){
$ending = 0;
$sumCreditBank = $sumCredit + $onePay;
for ($mounth = 1; $mounth <= 25; $mounth ++){
if ($sumCreditBank > $pay){
$sumCreditBank = ($sumCreditBank * $percent) + $gross - $pay;
}
else{
$pay = $sumCreditBank;
$sumCreditBank = 0;
}
$ending = $ending + $pay + $gross;
}
return $ending;
}
echo "HomoCredit Bank: {$homoCreditTotal} рублей \n";
echo "Soft Bank: {$softBankTotal} рублей \n";
echo "StrawBerry Bank: {$strawBerryBankTotal} рублей \n";
/*
$sumCredit - сумма кредита
$percent - проценты
$gross - комиссия
$pay - платеж
$onePay - доп платеж банка StrawBerry
*/
PD9waHAKZXJyb3JfcmVwb3J0aW5nICgtMSk7CgpmdW5jdGlvbiBiYW5rICgkc3VtQ3JlZGl0LCAkcGVyY2VudCwgJGdyb3NzLCAkcGF5LCAkb25lUGF5KXsKCSRlbmRpbmcgPSAwOwoJZm9yICgkbW91bnRoID0gMTsgJG1vdW50aCA8PSAyNTsgJG1vdW50aCArKyl7CgkJaWYgKCRzdW1DcmVkaXQgPiAkcGF5KXsKCQkJJHN1bUNyZWRpdCA9ICgkc3VtQ3JlZGl0ICogJHBlcmNlbnQpICsgJGdyb3NzIC0gJHBheTsKCQl9CgkJZWxzZXsKCQkJJHBheSA9ICRzdW1DcmVkaXQ7CgkJCSRzdW1DcmVkaXQgPSAwO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