Question: Write a function that will use a while loop to calculate and output how many years ( n ) it will take an initial investment

Write a function that will use a while loop to calculate and output how many years (n) it will take an initial investment (P0) to grow to more than a specified final value (Pfinal), given an interest rate (r). It should also store the yearly value of the investment in an array (bals).
Your function should use the following outputs, name and inputs: [n,bals]= makin_that_money(P0,Pfinal,r)
Once the number of years has been calculated, produce a graph of the principal at the beginning of each year. For example the first point should be: (0,P0) and the last point should be (n,SomethingALittleBitBiggerThanPfinal)
Be careful not to get stuck in an infinite loop! To receive full credit, you must use while loops and/or if statement to constrain the inputs to valid values.
IN MATLAB CODE

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!