<?php
//Баланс 39999, месячная плата 5000, гомо% 4, гомоком 500, софт%3, софтком 1000, страв%2, стравоткрытие 7777
function ipad( $hBalance , $sBalance , $stBalance , $monthPayment , $homoPercent , $homoService , $softPercent , $softService , $strawPercent , $strawOpen ) {
for ( $i = 1 ; $i = 100 ; $i ++ ) {
$hBalance = $hBalance * $homoPercent + $homoService ;
if ( $hBalance < $monthPayment ) {
$totalHomoPayment = $totalHomoPayment + $hBalance ;
break ;
}
else
{
$hBalance = $hBalance - $monthPayment ;
$totalHomoPayment = $totalHomoPayment + $monthPayment ;
}
}
for ( $i = 1 ; $i = 100 ; $i ++ ) {
$sBalance = $sBalance * $softPercent + $softService ;
if ( $sBalance < $monthPayment ) {
$totalSoftPayment = $totalSoftPayment + $sBalance ;
break ;
}
else
{
$sBalance = $sBalance - $monthPayment ;
$totalSoftPayment = $totalSoftPayment + $monthPayment ;
}
}
$stBalance = $stBalance + $strawOpen ;
for ( $i = 1 ; $i = 100 ; $i ++ ) {
$stBalance = $stBalance * $strawPercent ;
if ( $stBalance < $monthPayment ) {
$totalStrawPayment = $totalStrawPayment + $stBalance ;
break ;
}
else
$stBalance = $stBalance - $monthPayment ;
$totalStrawPayment = $totalStrawPayment + $monthPayment ;
}
return $totalHomoPayment .= $totalSoftPayment . $totalStrawPayment ;
}
$homoTotal = ipad( 39999 , 0 , 0 , 5000 , 1.04 , 500 , 0 , 0 , 0 , 0 ) ;
$softTotal = ipad( 0 , 39999 , 0 , 5000 , 0 , 0 , 1.03 , 1000 , 0 , 0 ) ;
$strawTotal = ipad( 0 , 0 , 39999 , 5000 , 0 , 0 , 0 , 0 , 1.02 , 7777 ) ;
echo "Гомобанк $homoTotal \n " ;
echo "Софтбанк $softTotal \n " ;
echo "Стравберри $strawTotal \n " ;
PD9waHAKZXJyb3JfcmVwb3J0aW5nKC0xKTsKLy/QkdCw0LvQsNC90YEgMzk5OTksINC80LXRgdGP0YfQvdCw0Y8g0L/Qu9Cw0YLQsCA1MDAwLCDQs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