Created
July 26, 2009 04:36
-
-
Save jasonnoble/155436 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'Date' | |
print "How much to save? " | |
save = gets.chomp.gsub('$', '').to_f | |
puts '' | |
print "When do you need it? (2009 12 25) " | |
(year, month, day) = gets.chomp.split(/\s+/).map{|m| m.to_i} | |
d = Date.new(year, month, day) | |
weeks = ((d - Date.today) / 7).to_i | |
amount = sprintf("%.02f", save / weeks) | |
puts '' | |
print "To save $#{'%.02f' % save} by #{month}/#{day}/#{year} (#{weeks} weeks)," | |
print " you need to save $#{amount} / week.\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment