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):
1000 dollars.1000 dollars and less than 5000 dollars.5000 dollars.You have four 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.5fNote that the value returned is a float.
Implement the (static) SavingsAccount.Interest() method to calculate the interest based on the specified balance:
SavingsAccount.Interest(balance: 200.75m)
// 1.00375mNote that the value returned is a decimal.
Implement the (static) SavingsAccount.AnnualBalanceUpdate() method to calculate the updated annual balance, taking into account the interest rate:
SavingsAccount.AnnualBalanceUpdate(balance: 200.75m)
// 201.75375mNote 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 given annually compounding interest:
SavingsAccount.YearsBeforeDesiredBalance(balance: 200.75m, targetBalance: 214.88m)
// 14Note that the value returned is an int.
When applying simple interest to a principal balance, the balance is multiplied by the interest rate and the product of the two is the interest amount.
Compound interest on the other hand is done by applying interest on a recurring basis. On each application the interest amount is computed and added to the principal balance so that subsequent interest calculations are subject to a greater principal balance.
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):
1000 dollars.1000 dollars and less than 5000 dollars.5000 dollars.You have four 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.5fNote that the value returned is a float.
Implement the (static) SavingsAccount.Interest() method to calculate the interest based on the specified balance:
SavingsAccount.Interest(balance: 200.75m)
// 1.00375mNote that the value returned is a decimal.
Implement the (static) SavingsAccount.AnnualBalanceUpdate() method to calculate the updated annual balance, taking into account the interest rate:
SavingsAccount.AnnualBalanceUpdate(balance: 200.75m)
// 201.75375mNote 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 given annually compounding interest:
SavingsAccount.YearsBeforeDesiredBalance(balance: 200.75m, targetBalance: 214.88m)
// 14Note that the value returned is an int.
When applying simple interest to a principal balance, the balance is multiplied by the interest rate and the product of the two is the interest amount.
Compound interest on the other hand is done by applying interest on a recurring basis. On each application the interest amount is computed and added to the principal balance so that subsequent interest calculations are subject to a greater principal balance.