#! /usr/bin/ruby # show results of compound interest begin p = ENV['p'].to_f r = ENV['r'].to_f y = ENV['y'].to_f r /= 100 p2 = p * ((1 + r) ** y) puts "ending principal: #{p2}\tgain: #{p2 - p}" rescue STDERR.puts "usage: p=1000 r=4.85 y=5 compound" end