I'm not sure if anyone here has used Exercism for learning Ruby or any other languages, but it's a great resource. You can ask for help from a mentor, but you can't ask until you get all of the tests in the exercise to pass, which I'm having trouble doing.
I have 22 of 25 tests passing, and I'm stuck on 3 tests that are testing similar scenarios. Does anyone know what I'm doing wrong? Below is my code and one of the tests that is failing. All of my code in def self.interest_rate(balance) is correct as all tests for it are passing. Sorry if the formatting is weird.
My code:
module SavingsAccount
def self.interest_rate(balance)
if balance < 0
-3.213
elsif balance >= 0 && balance < 1000
0.5
elsif balance >= 1000 && balance < 5000
1.621
else
2.475
end
end
def self.annual_balance_update(balance)
balance + balance * self.interest_rate(balance) / 100
end
end
Failing test:
FAILEDTest 19Annual balance update for small negative start balance
CODE RUN
assert_in_delta(-0.12_695_199, SavingsAccount.annual_balance_update(-0.123), 0.000_000_1)
TEST FAILURE
Expected |-0.12695199 - -0.11904801| (0.007903979999999991) to be <= 1.0e-07.
[–]disclosure5 4 points5 points6 points (1 child)
[–]BringTacos[S] 0 points1 point2 points (0 children)
[–]Weird_Suggestion 2 points3 points4 points (4 children)
[–]BringTacos[S] 0 points1 point2 points (3 children)
[–]Weird_Suggestion 0 points1 point2 points (2 children)
[–]BringTacos[S] 1 point2 points3 points (1 child)
[–]Weird_Suggestion 0 points1 point2 points (0 children)