Created
May 7, 2015 22:08
-
-
Save spraints/d520331db7a4ea8693da 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
# To demonstrate what a "Bank of Dad" would be like | |
require "date" | |
INTEREST_PER_MONTH = 0.1 | |
birthday = Date.today # replace this with the child's birthday | |
twentyone = 21.times.inject(birthday) { |d, _| d.next_year } | |
balance = 0.0 | |
now = Date.today | |
while now < twentyone | |
show = false | |
if now.day == 1 | |
balance = balance * (1.0 + INTEREST_PER_MONTH) | |
show = true | |
end | |
if now.sunday? | |
balance += 1.00 | |
show = true | |
end | |
if show | |
puts "#{now} $#{'%.2f' % balance}" | |
end | |
now = now.next_day | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment