Question: Use matlab code The lump sum S to be paid when interest on a loan is compounded annually is given by S = P(i +
The lump sum S to be paid when interest on a loan is compounded annually is given by S = P(i + i)^n where P is the principal invested, i is the interest rate, and n is the number of years. Write a program that will plot the amount S as it increases through the years from 1 to n. To complete this program you are to: Create a script that will: Call a function years. This function will ask the user to input three values: the principal amount (P), the interest rate (i), and the number of years (n). This function will also use error-checking with a while loop to ensure that the number of years input by the user is a positive number. Outputs for this function are: P, i, n. Call a function calculateS. This function will calculate the lump sum S for years 1 through n. Output for this function is: S. Call a function plotS. This function will plot S for years 1 through n. The plot is the only output for this function. The example below used .05 for the interest rate and $10,000 for P
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
