<?php
function getBalance($percent, $servicePayment, $creditBalance, $paymentTotal) {
$monthlyPayment = 5000;
for ($month = 1; $month <= 20; $month++) {
$creditBalance = ($creditBalance * $percent) + $servicePayment;
if ($creditBalance < 5000) {
$monthlyPayment = $creditBalance;
$paymentTotal = ($paymentTotal + $monthlyPayment);
$creditBalance = ($creditBalance - $monthlyPayment);
break;
} elseif ($creditBalance > 5000) {
$paymentTotal = ($paymentTotal + $monthlyPayment);
$creditBalance = ($creditBalance - $monthlyPayment);
}
}
return $paymentTotal;
}
$homoCreditTotal = getBalance(1.04, 500, 39999, 0);
$softBank = getBalance(1.03, 1000, 39999, 0);
$strawberryBank = getBalance(1.03, 0, 47776, 0);
echo "homocredit = $homoCreditTotal\n";
echo "softbank = $softBank\n";
echo "strawberrybank = $strawberryBank\n";
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CgpmdW5jdGlvbiBnZXRCYWxhbmNlKCRwZXJjZW50LCAkc2VydmljZVBheW1lbnQsICRjcmVkaXRCYWxhbmNlLCAkcGF5bWVudFRvdGFsKSB7CiAgICAkbW9udGhseVBheW1lbnQgPSA1MDAwOwogICAgZm9yICgkbW9udGggPSAxOyAkbW9udGggPD0gMjA7ICRtb250aCsrKSB7CgkkY3JlZGl0QmFsYW5jZSA9ICgkY3JlZGl0QmFsYW5jZSAqICRwZXJjZW50KSArICRzZXJ2aWNlUGF5bWVudDsKCWlmICgkY3JlZGl0QmFsYW5jZSA8IDUwMDApIHsKCQkkbW9udGhseVBheW1lbnQgPSAkY3JlZGl0QmFsYW5jZTsKCQkkcGF5bWVudFRvdGFsID0gKCRwYXltZW50VG90YWwgKyAkbW9udGhseVBheW1lbnQpOwoJCSRjcmVkaXRCYWxhbmNlID0gKCRjcmVkaXRCYWxhbmNlIC0gJG1vbnRobHlQYXltZW50KTsKCQlicmVhazsKCX0gZWxzZWlmICgkY3JlZGl0QmFsYW5jZSA+IDUwMDApIHsKCSRwYXltZW50VG90YWwgPSAoJHBheW1lbnRUb3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