<?php
/*Задача про айпад в кредит*/
function howMuch($percent, $servicePayment) {
$creditBalance = 39999; /*Долг анона*/
$monthlyPayment = 5000; /*Ежемесячные выплаты*/
$paymentTotal = 0; /*Уже выплатил*/
/*Проверка на StrawberryBank*/
if ($servicePayment == 0) {
$creditBalance += 7777;
}
/*Организуем цыкл, который будет повторяться, пока не выполнится первый if*/
for ($i = 1; $i <= 2; $i = 1)
{
if ($creditBalance <= $monthlyPayment)
{
$paymentTotal += $creditBalance;
return $paymentTotal;
break;
}
else
{
$creditBalance = ($creditBalance * $percent) + $servicePayment - $monthlyPayment;
$paymentTotal += $monthlyPayment;
}
}
}
/*Основная програма*/
$homoCredit = howMuch(1.04, 500);
$softBank = howMuch(1.03, 1000);
$strawberryBank = howMuch(1.02, 0);
echo "HomoCredit: {$homoCredit} рублей,\n";
echo "SoftBank: {$softBank} рублей,\n";
echo "StrawberryBank: {$strawberryBank} рублей";
?>
PD9waHAKLyrQl9Cw0LTQsNGH0LAg0L/RgNC+INCw0LnQv9Cw0LQg0LIg0LrRgNC10LTQuNGCKi8KZXJyb3JfcmVwb3J0aW5nKC0xKTsKCmZ1bmN0aW9uIGhvd011Y2goJHBlcmNlbnQsICRzZXJ2aWNlUGF5bWVudCkgewoJJGNyZWRpdEJhbGFuY2UgPSAzOTk5OTsgIC8q0JTQvtC70LMg0LDQvdC+0L3QsCovCgkkbW9udGhseVBheW1lbnQgPSA1MDAwOyAgLyrQldC20LXQvNC10YHRj9GH0L3Ri9C1INCy0YvQv9C70LDRgtGLKi8KCSRwYXltZW50VG90YWwgPSAwOyAgICAgICAvKtCj0LbQtSDQstGL0L/Qu9Cw0YLQuNC7Ki8KCQoJLyrQn9GA0L7QstC10YDQutCwINC90LAgU3RyYXdiZXJyeUJhbmsqLwoJaWYgKCRzZXJ2aWNlUGF5bWVudCA9PSAwKSB7CgkJJGNyZWRpdEJhbGFuY2UgKz0gNzc3NzsKCX0KCQoJLyrQntGA0LPQsNC90LjQt9GD0LXQvCDRht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