Created
November 3, 2022 23:12
-
-
Save rbclark/3d6947f693c911f8419ca5ecde5e7e00 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
require "readline" | |
CURRENT_INTEREST_RATE=6.97/100 | |
print "Input home value: " | |
value = gets.chomp.to_i | |
print "Input interest rate: " | |
rate = gets.chomp.to_f/100 | |
i = (1+rate/12)**(12/12)-1 | |
annuity = (1-(1/(1+i))**360)/i | |
payment = value/annuity | |
puts "\n$%.2f per month" % [payment] | |
current_i = (1+CURRENT_INTEREST_RATE/12)**(12/12)-1 | |
current_annuity = (1-(1/(1+current_i))**360)/current_i | |
current_value = current_annuity * payment | |
puts "For a 30 year mortgage the equivalent house value at current rates is: $%.2f" % [current_value] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment