fork download
  1. <?php
  2.  
  3. $deposit = 100;
  4. $rate = .05;
  5. // $rate = $rate / 100;
  6. $year = 0;
  7. $years = 5;
  8. $total = 0;
  9.  
  10.  
  11. while($year < $years){
  12. $year++;
  13. $deposit = $deposit + ($deposit * $rate);
  14. echo "<strong>Year " .$year . ": </strong>";
  15. if($year < $years) {
  16. echo number_format($deposit,2) ."\n";
  17. $deposit += 100;
  18. } else {
  19. echo "\n";
  20. }
  21.  
  22. $total = $deposit;
  23. }
  24.  
  25. echo "-------------------------" . "\n<strong> Total: </strong>" . number_format($total,2);
  26.  
Success #stdin #stdout 0.02s 24444KB
stdin
Standard input is empty
stdout
 <strong>Year 1: </strong>105.00
<strong>Year 2: </strong>215.25
<strong>Year 3: </strong>331.01
<strong>Year 4: </strong>452.56
<strong>Year 5: </strong>
-------------------------
<strong> Total: </strong>580.19