fork download
  1. <?php
  2.  
  3.  
  4. $creditBalance = 40000;
  5. $creditPercent = 1.03;
  6. $servicePayment = 1000;
  7. $payment = 5000;
  8. $totalPayment = 0;
  9.  
  10. for ($month = 1; $month <= 24; $month++) {
  11. $creditBalance = ( $creditBalance * $creditPercent ) + $servicePayment - $payment;
  12. $totalPaymnet = $totalPayment + $payment;
  13. echo "{$month} ago his credit balance = {$creditBalance} and his total paymeint is {$totalPayment}\n";
  14. if ($creditBalance <= 0) {
  15. echo"It is time to stop, now";
  16. break;
  17. }
  18. }
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
1 ago his credit balance = 37200 and his total paymeint is 0
2 ago his credit balance = 34316 and his total paymeint is 0
3 ago his credit balance = 31345.48 and his total paymeint is 0
4 ago his credit balance = 28285.8444 and his total paymeint is 0
5 ago his credit balance = 25134.419732 and his total paymeint is 0
6 ago his credit balance = 21888.45232396 and his total paymeint is 0
7 ago his credit balance = 18545.105893679 and his total paymeint is 0
8 ago his credit balance = 15101.459070489 and his total paymeint is 0
9 ago his credit balance = 11554.502842604 and his total paymeint is 0
10 ago his credit balance = 7901.137927882 and his total paymeint is 0
11 ago his credit balance = 4138.1720657184 and his total paymeint is 0
12 ago his credit balance = 262.31722768997 and his total paymeint is 0
13 ago his credit balance = -3729.8132554793 and his total paymeint is 0
It is time to stop, now