In this exercise you will be working with savings accounts. Each year, the balance of a savings account is updated based on the interest rate. The interest rate the bank gives depends on the amount of money in the accounts (its balance):
1000 dollars.1000 dollars and less than 5000 dollars.5000 dollars.You have three tasks, each of which will deal with the balance and its interest rate.
Implement the SavingsAccount.interest_rate method to calculate the interest rate based on the specified balance:
SavingsAccount.interest_rate(200.75)
#=> 0.5Note that the value returned is an instance of Float.
Implement the SavingsAccount.annual_balance_update method to calculate the annual balance update, taking into account the interest rate:
SavingsAccount.annual_balance_update(200.75)
#=> 201.75375Note that the value returned is an instance of Float.
Implement the SavingsAccount.years_before_desired_balance method to calculate the minimum number of years required to reach the desired balance:
SavingsAccount.years_before_desired_balance(200.75, 214.88)
#=> 14Note that the value returned is an instance of Integer.
In this exercise you will be working with savings accounts. Each year, the balance of a savings account is updated based on the interest rate. The interest rate the bank gives depends on the amount of money in the accounts (its balance):
1000 dollars.1000 dollars and less than 5000 dollars.5000 dollars.You have three tasks, each of which will deal with the balance and its interest rate.
Implement the SavingsAccount.interest_rate method to calculate the interest rate based on the specified balance:
SavingsAccount.interest_rate(200.75)
#=> 0.5Note that the value returned is an instance of Float.
Implement the SavingsAccount.annual_balance_update method to calculate the annual balance update, taking into account the interest rate:
SavingsAccount.annual_balance_update(200.75)
#=> 201.75375Note that the value returned is an instance of Float.
Implement the SavingsAccount.years_before_desired_balance method to calculate the minimum number of years required to reach the desired balance:
SavingsAccount.years_before_desired_balance(200.75, 214.88)
#=> 14Note that the value returned is an instance of Integer.