-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathchallenge_2.rb
More file actions
39 lines (30 loc) · 1.36 KB
/
challenge_2.rb
File metadata and controls
39 lines (30 loc) · 1.36 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
31
32
33
34
35
36
37
38
39
require './challenge_1.rb'
# Line 1 effectively copy-pastes in any code you wrote in challenge_1.rb
# It's similar to connecting an external stylesheet to an HTML file.
# So if you've already implemented the pmt method over there, then
# you don't have to rewrite it here.
# ===========
# CHALLENGE 2
# ===========
# Below is an array of hashes. Each hash in the array represents one rate
# quote from a bank.
loan_quotes = [
{ "bank" => "Elm Street Bank", "annual_rate" => 0.03875},
{ "bank" => "Oak Street Bank", "annual_rate" => 0.04076},
{ "bank" => "Ash Street Bank", "annual_rate" => 0.04000}
]
# Given some parameters of the loan, perhaps entered by a user on a web form:
number_of_monthly_payments = 30 * 12
principal_amount = 200000.0
# Now, loop through the array of loan quotes using .each:
# For each option, tell the user how much the monthly payment will be to
# that bank. E.g.,
# "The monthly payment from Elm Street Bank will be $xyz."
# Re-use the pmt method that you defined in Challenge 1. It is already
# available to you here because you connected to challenge_1.rb with
# Line 1 of this file.
# ==============================================================
# Your code goes here.
# You shouldn't have to write code or change code anywhere else.
# loan_quotes.each ...
# ==============================================================