Moving the interest calculation into a function

Computers are very good at adding numbers, as we’ve learned from all of our homework assignments. However, they can become even more efficient by creating sections of code that can be repeated over and over. These sections are not loops, but are functions. They take in parameters and return some result. 1 – Assignment Based on the success of your work calculating the compound interest, HP management wants you to make the code more efficient and portable by using functions. When talking about ‘interest’, we are talking about the bank giving you a percentage of your savings back to you. If you have 2% interest rate, and $1000 in your account, the bank will give you 1000*0.02, or $20 in interest. Usually this amount is calculated annually, called an “annual percentage rate” APR, meaning the bank will give you 2% over the entire year. So if you had $1000 in your account the entire year, you would get $20 at the end of the year. This feels like a long time to wait, so the bank calculates this interest monthly, but we won’t get into that in this assignment. Expand upon homework 4 by moving the interest calculation into a function. The function will take in a parameter, amount, and return a value, interest. Function CalculateInterest(amount As Double, interestRate As Double) As Double % write your code here Return ... %return val End Function Your program will have the same output at Homework 4. The only difference is that you will be calculating the interest in a function. Instead of amount = amount * 2, you will use your function amount = CalculateInterest(amount, 2). Note: ‘doubling’ your money is the same as 200% interest, or a modifier of 2.

Get Top-Notch Quality Essays TODAY !

Ready to join our block community of business leaders for four days of virtual sessions on driving developer happiness and boosting productivity?

Place Order