Question: Write a C++ function named CalculateInterestIncome to return the final amount given the original principal, the annual interest rate (percentage value like 4.3% example), the
Write a C++ function named CalculateInterestIncome to return the final amount given the original principal, the annual interest rate (percentage value like 4.3% example), the compounding frequency, the overall length of time the interest is applied. The total accumulated value, including the principal sum plus compounded interest , is given by the formula:
where:
- A is the final amount
- P is the original principal
- r is the annual interest rate as the absolute value-not as a percentage
- n is the compounding frequency
- t is the overall length of time the interest is applied (expressed using the same time units as r, usually years).
Example:
Suppose a principal amount of $1,500 is deposited in a bank paying an annual interest rate of 4.3%, compounded quarterly. Then the balance after 6 years is found by using the formula above, with P = 1500, r = 0.043, n = 4, and t = 6:
So the amount A after 6 years is approximately $1,938.84. Note the value of r in the formula is the absolute rate not percentage rate.
Do the following:
-
- Follow the UMPIRE process and write only the plan as a code comment
- Write your function
- Document what your function does as a code comment.
- Must pass r, the annual interest rate as a percentage
- In your main program, calculate the final amount for a principal amount of $2000.00 deposited in a bank paying an annual interest rate of 3.0%, compounded monthly for keeping 10 years.
// PLAN: //Follow the UMPIRE technique and write your PLAN below. Please comment out your writing. ... ... // IMPLEMENT: \#include ... \} // REVIEW: int main(int argc, char *argv[]) \{ // Print calls to your function for each data point in the order given in the problem statement. // See example below. double principal =100.; double annual rate =3.2; int frequency =12; double time =4.5; std::cout int(CalculateInterestIncome(principal, annual_rate, frequency, time)) std::endl; // Calculate the final return value for the test case given by printing int value of the call to your function, // CalculateInterestIncome. See the call above on using int(). ... ... return
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
