Question: % This script is has an error in it. Your goal is to find the error and % fix the program so it will work.

% This script is has an error in it. Your goal is to find the error and

% fix the program so it will work. Use the error message you get as a clue

% to fix the problem.

% The scritp uses the simple interest rate formula A=P(1+rt) to calculate

% the Accrued amount of money (A) that you would have investing some

% principle (P) at a given interest rate per year (r) for a given number of

% years. We will use this formulat to determine compound interest by

% putting it into a loop. Yes, there is a direct equation for calculating

% compound interest - look it up and see how close this method comes if you

% are curious.

% Set initial values:

P0 = 100; % One hundred dollars is the initial amount invested

rate= 0.03; % 3% annual interest rate

time = input ('how many years do you want to leave it there? ');

TotalAccrued = P0; % you start with your principle

for i=1:time

Accrued = P0(rate);

TotalAccrued = TotalAccrued + Acrued;

end

disp(TotalAccrued)

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!