In this exercise you'll be working with savings accounts. Each year, the balance of your savings account is updated based on its interest rate. The interest rate your bank gives you depends on the amount of money in your account (its balance):
- -3.213% for a negative balance.
- 0.5% for a positive balance less than
1000
dollars. - 1.621% for a positive balance greater or equal than
1000
dollars and less than5000
dollars. - 2.475% for a positive balance greater or equal than
5000
dollars.
You have three tasks, each of which will deal your balance and its interest rate.
Implement the (static) SavingsAccount.InterestRate()
method to calculate the interest rate based on the specified balance:
SavingsAccount.InterestRate(balance: 200.75m)
// 0.5f
Note that the value returned is a float
.
Implement the (static) SavingsAccount.AnnualBalanceUpdate()
method to calculate the annual balance update, taking into account the interest rate:
SavingsAccount.AnnualBalanceUpdate(balance: 200.75m)
// 201.75375m
Note that the value returned is a decimal
.
Implement the (static) SavingsAccount.YearsBeforeDesiredBalance()
method to calculate the minimum number of years required to reach the desired balance:
SavingsAccount.YearsBeforeDesiredBalance(balance: 200.75m, targetBalance: 214.88m)
// 14
Note that the value returned is an int
.