Question
USE MATLAB TO WRITE A CODE FOR THIS
2. Writ example 4.5% as 4.5) and the number of monthly payments (use the Calculate the down payment using the percent down payment e e a program that gets a cost, percent down payment, annual interest rate as a percent (for ntered, the loan amount (cost - own payment) and monthly interest rate as a decimal number -not a percent. Call your payment function to calculate the payment on the loan amount. With the payment and the number of months, calculate the total interest. Display the result of the calculations like the text below: The payment on a $40000.00 loan for 360 months at an interest rate of 4.00% is $190.97, and the total interest is $28747.80. Add the payment function to the end of your script as a local function. Add a comment line with your group number and the names of participating members. Save your programs as one script separated by %%. Have one member upload the script file to Canvas.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find required MATLAB code along with necessary details in comments below:

clc; % clear command window
clear all; % clear workspace

cost=input('Enter the cost:');
percent_down_payment=input('Enter the percent downpayment (in %):');
annual_intrest_rate=input('Enter the annual intrest rate (in %):');
num_months=input('Enter the number of monthly payment:');


down_payment=(percent_down_payment/100)*cost; % downpayment
loan_amount=cost-down_payment; % amount of loan
monthly_intrest_rate=annual_intrest_rate/12; % monthly intrest rate

payment_amt=payment(loan_amount,monthly_intrest_rate,num_months); % call payment function
total_intrest=(payment_amt*num_months)-loan_amount; % total intrest to be paid

% display the result
fprintf('The payment on a $%3.2f loan for %d months at an intrest rate of %3.2f%% is $%3.2f and the total intrest is $%3.2f', loan_amount,num_months,annual_intrest_rate,payment_amt,total_intrest)


function payment_amt=payment(loan_amount,monthly_intrest_rate,num_months)
% calculate the intrest
intrest=(loan_amount*monthly_intrest_rate*num_months)/100;
% total amount to be paid
amount= loan_amount+intrest;
% calculate monthly emi
payment_amt=amount/num_months;
end

----------------------------------- SCREENSHOT OF CODE

main-script-m X1 cic; % clear command window clear all; % clear workspace cost-input (Enter the cost:) percentdownpayment-input (Enter the percent downpayment (in %) :); annualintrestrate input( Enter the annual intrest rate (in %):); num months-input (Enter the number of monthly payment: - - - - 10- down payment. (percent, down payment/100)*cost; loan_amount-cost-down payment; monthly-intrest-rate=annual-intrest-rate/12; % downpayment % amount of loan 12 13 % monthly intrest rate paymentamt=payment (loanamount , monthlyintrestrate, num months); % call payment function totalintrest-paymentamt *num months)-loanamount; % total intrest to be paid ---- 15- 16 17 18 19 20 - - - % display the result fprintf( The payment on a s%3.2f 1 an for %d months at an intrest rate of %3.2f%% ís s%3.2f and the total intrest is s%3.2f, loanam - funct 刻payment-amt-payment (loan-amount, monthly-intrest-rate, num months) calculate the intrest intrest- (loan amount monthly intrest_rate num months)/100: 23 24 25amount- loan amounttintrest; 26 27payment_amt-amount/num months: % total amount to be paid calculate monthly emi end 29

------------------------------------------- SAMPLE OUTPUT

Add a comment
Know the answer?
Add Answer to:
USE MATLAB TO WRITE A CODE FOR THIS 2. Writ example 4.5% as 4.5) and the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT