fork(1) download
  1. <?php
  2. $deposit = 100;
  3. $rate = .05;
  4. $year = 0;
  5. $total = 100;
  6. $total_noninterest = 100;
  7.  
  8. echo "Year\tBalance\tInterest\tTotal\n";
  9. while($year < 5){
  10. echo str_pad($year, 5) . "\t";
  11. echo str_pad(number_format($total_noninterest,2), 10) . "\t";
  12. $interest += $total_noninterest * $rate;
  13. echo number_format($interest,2) . "\t";
  14.  
  15. $total += $total_noninterest + $interest;
  16. echo str_pad(number_format($total,2), 10) . "\n";
  17. $total_noninterest += $deposit;
  18. $year++;
  19. }
  20.  
  21. //echo "-------------------------" . "\n<strong> Total: " . number_format($total,2);
  22.  
Success #stdin #stdout #stderr 0.01s 24360KB
stdin
Standard input is empty
stdout
 Year	Balance	Interest	Total
0    	100.00    	5.00	205.00    
1    	200.00    	15.00	420.00    
2    	300.00    	30.00	750.00    
3    	400.00    	50.00	1,200.00  
4    	500.00    	75.00	1,775.00  
stderr
PHP Notice:  Undefined variable: interest in /home/ymbitF/prog.php on line 12