{"id":540,"date":"2011-02-15T19:46:28","date_gmt":"2011-02-16T00:46:28","guid":{"rendered":"http:\/\/www.xavignu.com\/?p=540"},"modified":"2011-02-15T19:46:28","modified_gmt":"2011-02-16T00:46:28","slug":"savings-script","status":"publish","type":"post","link":"https:\/\/www.xavignu.com\/?p=540","title":{"rendered":"Savings script"},"content":{"rendered":"<p>So I was thinking about writing a script to calculate the savings over a certain matter of time and came up with the following.<\/p>\n<p>[perl]<br \/>\n#!\/usr\/bin\/perl<\/p>\n<p>use warnings;<br \/>\nuse strict;<\/p>\n<p>print &quot;What is the yield?\\n&quot;;<br \/>\nmy $yield = &lt;&gt;;<br \/>\nprint &quot;How many years?\\n&quot;;<br \/>\nmy $years = &lt;&gt;;<br \/>\nprint &quot;How much money saved anually?\\n&quot;;<br \/>\nmy $savings = &lt;&gt;;<br \/>\nmy $i;<br \/>\nmy $new_savings = 0;<\/p>\n<p>for($i = 1; $i &lt;= $years; $i++) {<br \/>\n\t$new_savings = $savings + $new_savings;<br \/>\n\t$new_savings = $new_savings + $new_savings*($yield\/100);<br \/>\n\tprintf &quot;Savings for year $i are \\$%.2f.\\n&quot;, $new_savings;<br \/>\n}<br \/>\n[\/perl]<\/p>\n<p>Below is an usage example.<\/p>\n<p>[19:43:04] xavi@ubuntu:\/tmp $ .\/yield.pl<br \/>\nWhat is the yield?<br \/>\n5.0<br \/>\nHow many years?<br \/>\n5<br \/>\nHow much money saved anually?<br \/>\n10000<br \/>\nSavings for year 1 are $10500.00.<br \/>\nSavings for year 2 are $21525.00.<br \/>\nSavings for year 3 are $33101.25.<br \/>\nSavings for year 4 are $45256.31.<br \/>\nSavings for year 5 are $58019.13.<br \/>\n[19:43:18] xavi@ubuntu:\/tmp $ <\/p>\n<p>This just gives an idea of the money that can be saved over a short period of time with a five percent yield. It&#8217;s a really simple script.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So I was thinking about writing a script to calculate the savings over a certain matter of time and came up with the following. [perl] #!\/usr\/bin\/perl use warnings; use strict; print &quot;What is the yield?\\n&quot;; my $yield = &lt;&gt;; print &quot;How many years?\\n&quot;; my $years = &lt;&gt;; print &quot;How much money saved anually?\\n&quot;; my $savings [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[3],"tags":[22,6,50,70],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/pTQgt-8I","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts\/540"}],"collection":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=540"}],"version-history":[{"count":0,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts\/540\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=540"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}