<?php
$creditSum = 39999;
$payout = 5000;
$totalPaymentHomo = 0;
$totalPaymentSoft = 0;
$totalPaymentStrawberry =0;
class Bank
{
public $percent;
public $credit;
public $servicePay;
}
$homoBank = new Bank;
$homoBank->percent = 0.04;
$homoBank->credit = $creditSum;
$homoBank->servicePay = 500;
for ($i = 1; $i < 15; $i++){
$homoBank->credit = $homoBank->credit + ($homoBank->credit * $homoBank->percent);
$homoBankPayment = $homoBank->credit - ($payout - $homoBank->servicePay);
$homoBank->credit = $homoBankPayment;
$totalPaymentHomo = $totalPaymentHomo + $payout;
echo $homoBank->credit . "<br>" . $totalPaymentHomo . "</br>";
if ($homoBank->credit < 0){
echo "<b>Кредит выплачен за $i месяцев, всего ушло на погашение $totalPaymentHomo</b><br>";
break;
}
}
$Softbank = new Bank;
$Softbank->percent = 0.03;
$Softbank->credit = $creditSum;
$Softbank->servicePay = 1000;
for ($i = 1; $i < 15; $i++){
$Softbank->credit = $Softbank->credit + ($Softbank->credit * $Softbank->percent);
$SoftbankPayment = $Softbank->credit - ($payout - $Softbank->servicePay);
$Softbank->credit = $SoftbankPayment;
$totalPaymentSoft = $totalPaymentSoft + $payout;
echo $Softbank->credit . "<br>" . $totalPaymentSoft . "</br>";
if ($Softbank->credit < 0){
echo "<b>Кредит выплачен за $i месяцев, всего уйдет на погашение $totalPaymentSoft</b><br>";
break;
}
}
$StrawberryBank = new Bank;
$StrawberryBank->percent = 0;
$StrawberryBank->credit = $creditSum + 7777;
$StrawberryBank->servicePay = 0;
for ($i = 1; $i < 15; $i++){
$StrawberryBank->credit = $StrawberryBank->credit + ($StrawberryBank->credit * $StrawberryBank->percent);
$StrawberryBankPayment = $StrawberryBank->credit - ($payout - $StrawberryBank->servicePay);
$StrawberryBank->credit = $StrawberryBankPayment;
$totalPaymentStrawberry = $totalPaymentStrawberry + $payout;
echo $StrawberryBank->credit . "<br>" . $totalPaymentStrawberry . "</br>";
if ($StrawberryBank->credit < 0){
echo "<b>Кредит выплачен за $i месяцев, всего ушло на погашение $totalPaymentStrawberry</b><br>";
break;
}
}
?>