fork download
  1. <?php
  2. $payIn=5000;
  3. $percentTax=1.03;
  4. $bankTax=1000;
  5. $kreditSize=40000;
  6. $totalPay=0;
  7. $oddMoney=0;
  8. $overpayments=0;
  9. $finalAmountOfPaidMoney=0;
  10. for ($bodyLoan=40000,$n=1;$bodyLoan > 0;$n++) {
  11. $bodyLoan=($bodyLoan*$percentTax)+$bankTax;
  12. if ($bodyLoan >= 5000) {
  13. $bodyLoan=$bodyLoan-$payIn;
  14. $totalPay = $payIn * $n;
  15. echo "the body of the loan for a $n month is: $bodyLoan RUB\n";
  16. }
  17. else {
  18. echo "Body of the loan lower than 5000 RUB!\n";
  19. echo "the body of the loan for a $n month is: $bodyLoan RUB\n";
  20. $oddMoney=$payIn - $bodyLoan;
  21. $finalAmoutOfPaidMoney=$totalPay-$oddMoney;
  22. $overpayments=$finalAmoutOfPaidMoney-$kreditSize;
  23. echo "The change from the last payment was: $oddMoney RUB\n";
  24. echo "Total for the loan was paid: $finalAmoutOfPaidMoney RUB\n";
  25. echo "Overpayments state: $overpayments RUB\n";
  26. break;
  27. }
  28. }
Success #stdin #stdout 0.01s 82880KB
stdin
Standard input is empty
stdout
the body of the loan for a 1 month is: 37200 RUB
the body of the loan for a 2 month is: 34316 RUB
the body of the loan for a 3 month is: 31345.48 RUB
the body of the loan for a 4 month is: 28285.8444 RUB
the body of the loan for a 5 month is: 25134.419732 RUB
the body of the loan for a 6 month is: 21888.45232396 RUB
the body of the loan for a 7 month is: 18545.105893679 RUB
the body of the loan for a 8 month is: 15101.459070489 RUB
the body of the loan for a 9 month is: 11554.502842604 RUB
the body of the loan for a 10 month is: 7901.137927882 RUB
the body of the loan for a 11 month is: 4138.1720657184 RUB
the body of the loan for a 12 month is: 262.31722768997 RUB
Body of the loan lower than 5000 RUB!
the body of the loan for a 13 month is: 1270.1867445207 RUB
The change from the last payment was: 3729.8132554793 RUB
Total for the loan was paid: 56270.186744521 RUB
Overpayments state: 16270.186744521 RUB