So I was thinking about writing a script to calculate the savings over a certain matter of time and came up with the following.
#!/usr/bin/perl use warnings; use strict; print "What is the yield?\n"; my $yield = <>; print "How many years?\n"; my $years = <>; print "How much money saved anually?\n"; my $savings = <>; my $i; my $new_savings = 0; for($i = 1; $i <= $years; $i++) { $new_savings = $savings + $new_savings; $new_savings = $new_savings + $new_savings*($yield/100); printf "Savings for year $i are \$%.2f.\n", $new_savings; }
Below is an usage example.
[19:43:04] xavi@ubuntu:/tmp $ ./yield.pl
What is the yield?
5.0
How many years?
5
How much money saved anually?
10000
Savings for year 1 are $10500.00.
Savings for year 2 are $21525.00.
Savings for year 3 are $33101.25.
Savings for year 4 are $45256.31.
Savings for year 5 are $58019.13.
[19:43:18] xavi@ubuntu:/tmp $
This just gives an idea of the money that can be saved over a short period of time with a five percent yield. It’s a really simple script.