<?php
function findBank($find, $bankRating) {
return $find;
}
function creditCalc($credit, $firstPay,$percent, $comission, $mountPay){
$totalPay = 0;
if ($firstPay != 0){
$credit = $credit + $firstPay;
}
for($i = 0; $credit > 0; $i++){
$mountPercent = round(($credit + $comission) * $percent/100, 2); $credit = $credit + $mountPercent + $comission;
if ($credit < $mountPay){
$mountPay = $credit;
}
$credit = $credit - $mountPay;
$totalPay = $totalPay + $mountPay;
}
return $totalPay;
}
$credit = 39999;
$mountPay = 5000;
$homoCreditTotal = creditCalc($credit, 0, 4, 500, $mountPay);
$softbankTotal = creditCalc($credit, 0, 3, 1000, $mountPay);
$strawberrybank = creditCalc($credit, 7777, 2, 0, $mountPay);
echo "Хоум-кредит: {$homoCreditTotal}\n";
echo "Софтбанк: {$softbankTotal}\n";
echo "Клубничка-банк: {$strawberrybank}\n";
'Хоум-кредит' => $homoCreditTotal,
'Софтбанк' => $softbankTotal,
'Клубничка-банк' => $strawberrybank
);
$bestBank = findBank
(min($bankRating),$bankRating); $worstBank = findBank
(max($bankRating),$bankRating);
echo "Банк с наименьшей переплатой: {$bestBank}\n";
echo "Банк с наибольшей переплатой: {$worstBank}\n";
?>
PD9waHAKCgplcnJvcl9yZXBvcnRpbmcoLTEpOwoKZnVuY3Rpb24gZmluZEJhbmsoJGZpbmQsICRiYW5rUmF0aW5nKSB7CiAgICAgICAgJGZpbmQgPSBhcnJheV9zZWFyY2goJGZpbmQsICRiYW5rUmF0aW5nKTsKICAgICAgICByZXR1cm4gJGZpbmQ7CiAgICAgICAgfQoKZnVuY3Rpb24gY3JlZGl0Q2FsYygkY3JlZGl0LCAkZmlyc3RQYXksJHBlcmNlbnQsICRjb21pc3Npb24sICRtb3VudFBheSl7CiAgICAgICAgJHRvdGFsUGF5ID0gMDsKICAgICAgICBpZiAoJGZpcnN0UGF5ICE9IDApewogICAgICAgICAgICAgICAgJGNyZWRpdCA9ICRjcmVkaXQgKyAkZmlyc3RQYXk7CiAgICAgICAgfQogICAgICAgIGZvcig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