-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathchallenge_1.rb
More file actions
30 lines (24 loc) · 1.04 KB
/
challenge_1.rb
File metadata and controls
30 lines (24 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# ===========
# CHALLENGE 1
# ===========
# Suppose we are building a loan payment calculator.
# Define a method called "pmt" which will accept three arguments:
# - interest rate
# - number of payments
# - principal value of loan
# The method should return the size of each payment given these three things.
# Before we can teach the computer how to automate a task,
# we usually have to do some research on how the task is done:
# http://en.wikipedia.org/wiki/Mortgage_calculator
def pmt(rate, nper, pv)
# =========================================================
# Your code to implement the method goes here.
# You shouldn't have to write or change code anywhere else.
# =========================================================
end
# Example usage of the method is below. Uncomment to test your pmt method,
# and once you have successfully defined it, re-comment them (before
# starting challenge_2.rb).
# the_payment = pmt(0.0404/12, 60, 30000)
# puts "Your monthly payment will be $#{the_payment.round(2)}."
# You should get $553.04.