Question

In: Computer Science

Language: matlab It is desired to create a mortgage estimator by writing a program containing a...

Language: matlab

It is desired to create a mortgage estimator by writing a program containing a function. The user inputs the amount of loan (L), the loan term in number of months (N), and the annual interest rate (I) in the script. The script then makes use of a function that accepts these values as inputs through its argument and calculates and returns the monthly payment and the total payments over the life of the loan. The monthly payment and the total payment could be calculated using the following expressions:

m o n t h l y − p a y m e n t = L /(( 1 − ( 1 + I/ 12 ) ^(− N)} /( I /12 ) )

t o t a l − p a y m e n t = m o n t h l y − p a y m e n t ( N )

Note that the interest rate must be expressed in decimal; for example, if the interest rate is 8% it must be entered as 0.08 . Test your program for several scenarios and submit the results with the program listing.

The values of L, N, I, monthly_payment, and total_payment should be written to a file as shown below (payments should have only two decimal places):

  Loan Amount     Interest     Months     Monthly Payment     Total Payment

10000 0.06 36 …. ….
120000 0.05 108 …. ….
85000 0.07 48 …. ….
257000 0.08 240 …. ….
320000 0.05 120 …. ….

Submit a copy of the script file, the function file, and the output file containing the above tabular output.

could you type code for each file(script,function, and output)

Solutions

Expert Solution

`Hey,

Note: If you have any queries related to the answer please do comment. I would be very happy to resolve all your queries.

clc

clear all

close all

format long

L=input('Enter loan amount: ');

R=input('Enter rate of interest: ');

N=input('Enter number of months: ');

M=getMonthly(L,R,N)

fid = fopen('out.txt', 'a+');

fprintf(fid, '%d\t%.2f\t%d\t%.2f\t%.2f\n', L,R/100,N,M,M*N);

fclose(fid);

function M=getMonthly(L,R,N)

r=R/N;

M=L/((1-(1+r/12)^(-N))/(r/12));

end

Kindly revert for any queries

Thanks.


Related Solutions

Create a Matlab program that can evaluate Green Theorem
Create a Matlab program that can evaluate Green Theorem
A question about exceptions, the language is JAVA. The purpose is writing a program that reads...
A question about exceptions, the language is JAVA. The purpose is writing a program that reads a string from the keyboard and tests whether it contains a valid time. Display the time as described below if it is valid, otherwise display a message as described below. The input date should have the format hh:mm:ss (where hh = hour, mm = minutes and ss = seconds in a 24 hour clock , for example 23:47:55). Here are the input errors (Exceptions)...
this program is to be done in c language. Using Pointers Create a program pointerTester.c to...
this program is to be done in c language. Using Pointers Create a program pointerTester.c to experiment with pointers. Implement the following steps one by one in your program: YOU NEED TO ANSWER QUESTION Use printf to print your answers at the end(after 12). 1. Declare three integer variables a, b and c. Initialize them to 0, 100 and 225, respectively. 2. Print the value of each variable and its address. 3. Add the following declaration to your code: int...
** USING MATLAB TO PROGRAM The main objective of this lab is to create a game...
** USING MATLAB TO PROGRAM The main objective of this lab is to create a game that involves betting on the sum of two dice. The player will start out with some initial total amount of money. During each round, the player can bet some money that the sum of the two dice will be equal to a certain number. If the player wins the bet, that player adds the amount of the bet to his or her current total....
This is a Matlab Question Create MATLAB PROGRAM that can solve First Order Linear Differential Equation...
This is a Matlab Question Create MATLAB PROGRAM that can solve First Order Linear Differential Equation ( 1 example contains condition and the other does not have condition). 1. ty′ + 2y = t^2 − t + 1, y(1)=12 The correct answer is y(t) = 1/4 t^2 − 1/3 t + 1/2 + 1/12t^2 2. (x-1) dy/dx + 2y = (x+1)^2 The correct answer is y = (x(x+1) / x-1 ) + C(x+1) / x-1 The correct answer is
MATLAB is program Respond fast please a quiz Create a MATLAB script. Using nested for loops,...
MATLAB is program Respond fast please a quiz Create a MATLAB script. Using nested for loops, evaluate the multivariable function: z = sin ⁡ ( x ) cos ⁡ ( y ) for x between -4 and 4 in steps of 1 y between -2 and 2 in steps of 1 Display the matrix z Cut and paste the following into a word doc and submit to this question. Your script code Your input Your output
Programing Language: Java The Problem: You are writing a program that encrypts or decrypts messages using...
Programing Language: Java The Problem: You are writing a program that encrypts or decrypts messages using a simple substitution cipher. Your program will use two constant strings. One will represent the code for encryption: going from the original message (called the plaintext) to the encrypted version of the message. The other will be “abcdefghijklmnopqrstuvwxyz” (the lowercase alphabet. Your program will ask the user whether they want to 1) encrypt a message, 2) decrypt a message, or 3) quit. If they...
I am writing a matlab program where I created a figure that has a few different...
I am writing a matlab program where I created a figure that has a few different elements to it and now I need to move that figure into a specific excel file into a specific set of boxes in the excel file. With numbers and text I have always used the xlswrite function for this in order to put data into specific boxes. How do I do the same with this figure? The figure I have is called like this:...
How would you go about writing a MATLAB program to convert a phrase in Pig Latin...
How would you go about writing a MATLAB program to convert a phrase in Pig Latin to English. I have already written a script that converts phrases from English into Pig Latin; however, I am not sure how to reverse the process. Can anyone who know's MATLAB please help me out, thank you? P.S. I know that this is an unambigious task so it doesn't have to work completely well. With the most minor assumptions made, if it could covert...
Need to create Mortgage Calculator Program In C++ Modify your mortgage to include two functions. A...
Need to create Mortgage Calculator Program In C++ Modify your mortgage to include two functions. A function to get principal, rate, and term. A function to calculate monthly payment. Test your program by getting the data from the user by using the first function and calculate monthly payment by calling the other function. Add version control and write proper comments with a few blank lines & indentations in order to improve your programming style.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT