Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% Loan Payments Over Time
- % Calculates and prints loan payments
- clc, clear
- % Inputs and Variables
- A0 = input('What is the initial loan amount?\n');
- R = input('What is the yearly interest rate?\n')/12;
- N = input('How many months do you want it to take?\n');
- % Outputs and Equations
- P = A0*( R*( 1 + R )^N)/( ( 1+R )^N -1 );
- n = 1;
- A = A0;
- while A > 0
- I = A * R;
- PP = P - I;
- Afin = A - P + I;
- Afin = round( Afin, 2);
- I = round( I, 2 );
- PP = round( PP, 2 );
- fprintf( 'Payment %i: Initial Balance $%.2f Payment $%.2f Interest: $%.2f \n Principal Paid: $%.2f New Balance: $%.2f \n', n, A, I, P, PP, Afin)
- n = n + 1;
- A = Afin;
- end % while
- %{
- The user will be asked what their interest rate is for the year, it needs to be entered
- in decimal form. The interest rate will be saved as a monthly rate. To change
- this edit line 8.
- %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement