<?php
/* Задача про iPad в кредит http://a...content-available-to-author-only...d.ru/l1/functions.html */
$credit = 39999 ;
$monthlyPayment = 5000 ;
$homo = array ( 'HomoCredit' , 0.04 , 500 , 0 ) ; /* в массивах даны имя банка, ставка, комиссия и стоимость открытия счета)*/ $soft = array ( 'Softbank' , 0.03 , 1000 , 0 ) ; $strawberry = array ( 'Strawberry Bank' , 0.02 , 0 , 7777 ) ;
function getTotal( $bank , $credit , $monthlyPayment )
{
$monthlyTax = $bank [ 2 ] ; /* комиссия */
$startTax = $bank [ 3 ] ; /* стоимость открытия */
$balance = $credit + $startTax ; /* текущий размер кредита */
$percent = $bank [ 1 ] ; /* процент */
$month = 0 ;
for ( $total = 0 ; $balance > 0 ; $month ++ ) {
if ( $balance > $monthlyPayment ) {
$balance = $balance + $percent + $monthlyTax ;
$total = $total + $monthlyPayment ;
$balance = $balance - $monthlyPayment ;
} else {
$total = $total + $balance ;
break ;
}
}
echo "\n ************** \n БАНК {$bank[0]} \n Кредит погашен на {$month} м месяце.\n Сумма выплат составила {$total} грн. \n ************** \n " ;
}
getTotal( $homo , $credit , $monthlyPayment ) ;
getTotal( $soft , $credit , $monthlyPayment ) ;
getTotal( $strawberry , $credit , $monthlyPayment ) ;
PD9waHAKCi8qINCX0LDQtNCw0YfQsCDQv9GA0L4gaVBhZCDQsiDQutGA0LXQtNC40YIgIGh0dHA6Ly9hLi4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi5kLnJ1L2wxL2Z1bmN0aW9ucy5odG1sICovCgokY3JlZGl0ICAgICAgICAgPSAzOTk5OTsKJG1vbnRobHlQYXltZW50ID0gNTAwMDsKJGhvbW8gICAgICAgICAgID0gYXJyYXkoJ0hvbW9DcmVkaXQnLCAwLjA0LCA1MDAsIDApOyAvKiDQsiDQvNCw0YHRgdC40LLQsNGFINC00LDQvdGLINC40LzRjyDQsdCw0L3QutCwLCDRgdGC0LDQstC60LAsINC60L7QvNC40YHRgdC40Y8g0Lgg0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KICAgIH0KICAgIAogICAgZWNobyAiXG4qKioqKioqKioqKioqKiBcbtCR0JDQndCaIHskYmFua1swXX0gXG7QmtGA0LXQtNC40YIg0L/QvtCz0LDRiNC10L0g0L3QsCB7JG1vbnRofdC8INC80LXRgdGP0YbQtS5cbtCh0YPQvNC80LAg0LLRi9C/0LvQsNGCINGB0L7RgdGC0LDQstC40LvQsCB7JHRvdGFsfdCz0YDQvS4gXG4qKioqKioqKioqKioqKiBcbiI7Cn0KCmdldFRvdGFsKCRob21vLCAkY3JlZGl0LCAkbW9udGhseVBheW1lbnQpOwpnZXRUb3RhbCgkc29mdCwgJGNyZWRpdCwgJG1vbnRobHlQYXltZW50KTsKZ2V0VG90YWwoJHN0cmF3YmVycnksICRjcmVkaXQsICRtb250aGx5UGF5bWVudCk7