

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


% Assignment 10 % Ridwan_Abdi % This code is used to calculate Uniform payment of given interest rate, years % % and principal amount. % clear all cache and windows clear; close all; clc; %input needed data P = input('Enter principal in dollars: '); years = input('Enter number of years: '); %print header to screen fprintf('****************************************************\n') fprintf(' STUDENT LOAN PAYMENT CALCULATIONS\n\n') %print input formatSpec = 'Principal = $%.0f'; fprintf(formatSpec,P); disp('\n\n') %Calculations n = years12; r = 1:0.5:9; r = r/12; R = interp1(1:numel(r), r, linspace(1,numel(r),n), 'nearest'); A = zeros(1,n); for ii=1:n A(ii) = P.((R(ii).*((1+R(ii)).^n))/(((1+R(ii)).^n)-1)); end output = [R; A]; disp('Interest Rate Monthly Payment'); formatSpec = ' %4.2f %7.2f\n'; fprintf(formatSpec, output); %print results % disp(' %4.2f %7.2f',r,A)
Enter principal in dollars: 300 Enter number of years: 2
STUDENT LOAN PAYMENT CALCULATIONS Principal = $300\n\n Interest Rate Monthly Payment 0.08 29.