Application 8: Loan Calculator GUI ENGR 1221 Designed to test skills with: GUIs, user-defined functions. In this exercise you will create a GUI that calculates values for a loan. There are 4 variables...

1 answer below »
attached file


Application 8: Loan Calculator GUIENGR 1221 Designed to test skills with: GUIs, user-defined functions. In this exercise you will create a GUI that calculates values for a loan. There are 4 variables (listed below). You will enter 3 of these into the GUI then calculate the 4th using 1 of 4 equations. General guidelines for all assignments: (1) complete using a script file unless otherwise noted; (2) submit all your work [e.g. script, command window, function files, figures]   See detailed submission instructions (Carmen/Content/Submission Instructions)  Task 1: GUI Functions Create four external user-defined functions (each with 3 inputs, 1 output, a unique name, and thorough comments) corresponding to the four calculations described below. Test all of the functions with the test case shown below by calling each either from a separate script file or from function main. Calculate all variations of this test case where 3 of the 4 values are specified and the function produces the correct 4th value. Notice the equations use the monthly interest rate while your functions will have the annual interest rate as an input Variable Description Test Case P Monthly Payment 399.25 A Principal Amount of Loan 17,000 N Number of monthly payments 48 I Annual Interest Rate 6% i Monthly Interest Rate (I/12)/100 Monthly Payment Amount P given A, N, and I: Number of Payments N given P, A, and I: Principal Loan Amount A given P, N, and I: Interest Rate I given P, A, and N (Iterative Method): There is no closed form interest rate formula. Instead, the Newton iterative method is used on a modified form of the basic loan equation. This method works by inserting an initial guess for the interest rate (I = 10%), then looking at the difference between the calculated (), and the guessed interest (). If that difference is larger than your specifications, you take the calculated interested rate, insert it as the new (), then again calculate (), and then finally compare those values. You continue this process until you get to a minor difference (diff <= 10e-6). newton’s iterative form for interest rate is: a while loop is the preferred method of calculating using the above equation because the number of required repetitions is indefinite (and we can use the while loop condition to test for our preferred iteration difference). remember that () is the monthly interest, e.g. = .005 = (6/12)/100 for a 6% annual interest rate, assuming monthly payments. task 2: gui creation layout the following gui using guide. feature list: · 5 panels (1 for overall) · 5 static text boxes · 4 editable text boxes · 3 pushbuttons delete the text from the 4 editable text boxes. modify the tag properties to another valid and sensible name. use the image below as a guide. if desired print or save this figure and label the gui elements with their tag, this will be helpful with programming. feel free to be creative with the gui’s appearance by changing the colors and fonts (but be reasonable). task 3: gui programming complete the loan gui that takes three user inputs from editable text boxes, solves for the missing value, and displays it in the empty box. the following steps will guide you: 1. make sure your functions from earlier are in the same directory as the gui function (or at the bottom of your gui main function). 2. add functionality to the “calculate” button: a. obtain the values from the editable text boxes. b. determine if there is sufficient information from the user. i. if less than 3 of the boxes are filled, then give an error message to the user. ii. if all 4 boxes are filled, then give a different message to the user. c. if 3 boxes are filled, call the correct user-defined function with the given inputs to calculate the missing value. d. display the calculated result in the empty editable text box. 3. add code to the “clear all” button that will reset all the text boxes (delete all text in them). 4. add code to the “exit” button that will clear everything and close everything. hint: guis are figure windows in matlab. 5. submit screen shots of all test cases (minimum of 6): a. 4 working calculations (1 for each variable). b. 1 with an error message. c. 1 for clear windows. hints: 1. you can use the isempty() command to determine if a variable is empty. 2. determining how many user inputs have been provided can be the most challenging portion of this task. there are a number of valid approaches, but here is a hint to guide you towards what could be a better solution: the length command can be used within a single condition to evaluate whether exactly 3 numbers have been provided in the text boxes. 3. use conditional statements to select the proper equation. if you know that there are exactly 3 inputs, then there are only 4 other possible situations (missing a, i, n, or p) and that equation should be used. 4. you may need to use some debugging techniques to make your code work properly. in order to detect errors, consider: a. using the debugger with breakpoints set within the suspected callback. b. temporarily un-suppressing certain lines of code. c. making extra displays on the gui. 10e-6).="" newton’s="" iterative="" form="" for="" interest="" rate="" is:="" a="" while="" loop="" is="" the="" preferred="" method="" of="" calculating="" using="" the="" above="" equation="" because="" the="" number="" of="" required="" repetitions="" is="" indefinite="" (and="" we="" can="" use="" the="" while="" loop="" condition="" to="" test="" for="" our="" preferred="" iteration="" difference).="" remember="" that="" ()="" is="" the="" monthly="" interest,="" e.g.=".005" =="" (6/12)/100="" for="" a="" 6%="" annual="" interest="" rate,="" assuming="" monthly="" payments.="" task="" 2:="" gui="" creation="" layout="" the="" following="" gui="" using="" guide.="" feature="" list:="" ·="" 5="" panels="" (1="" for="" overall)="" ·="" 5="" static="" text="" boxes="" ·="" 4="" editable="" text="" boxes="" ·="" 3="" pushbuttons="" delete="" the="" text="" from="" the="" 4="" editable="" text="" boxes.="" modify="" the="" tag="" properties="" to="" another="" valid="" and="" sensible="" name.="" use="" the="" image="" below="" as="" a="" guide.="" if="" desired="" print="" or="" save="" this="" figure="" and="" label="" the="" gui="" elements="" with="" their="" tag,="" this="" will="" be="" helpful="" with="" programming.="" feel="" free="" to="" be="" creative="" with="" the="" gui’s="" appearance="" by="" changing="" the="" colors="" and="" fonts="" (but="" be="" reasonable).="" task="" 3:="" gui="" programming="" complete="" the="" loan="" gui="" that="" takes="" three="" user="" inputs="" from="" editable="" text="" boxes,="" solves="" for="" the="" missing="" value,="" and="" displays="" it="" in="" the="" empty="" box.="" the="" following="" steps="" will="" guide="" you:="" 1.="" make="" sure="" your="" functions="" from="" earlier="" are="" in="" the="" same="" directory="" as="" the="" gui="" function="" (or="" at="" the="" bottom="" of="" your="" gui="" main="" function).="" 2.="" add="" functionality="" to="" the="" “calculate”="" button:="" a.="" obtain="" the="" values="" from="" the="" editable="" text="" boxes.="" b.="" determine="" if="" there="" is="" sufficient="" information="" from="" the="" user.="" i.="" if="" less="" than="" 3="" of="" the="" boxes="" are="" filled,="" then="" give="" an="" error="" message="" to="" the="" user.="" ii.="" if="" all="" 4="" boxes="" are="" filled,="" then="" give="" a="" different="" message="" to="" the="" user.="" c.="" if="" 3="" boxes="" are="" filled,="" call="" the="" correct="" user-defined="" function="" with="" the="" given="" inputs="" to="" calculate="" the="" missing="" value.="" d.="" display="" the="" calculated="" result="" in="" the="" empty="" editable="" text="" box.="" 3.="" add="" code="" to="" the="" “clear="" all”="" button="" that="" will="" reset="" all="" the="" text="" boxes="" (delete="" all="" text="" in="" them).="" 4.="" add="" code="" to="" the="" “exit”="" button="" that="" will="" clear="" everything="" and="" close="" everything.="" hint:="" guis="" are="" figure="" windows="" in="" matlab.="" 5.="" submit="" screen="" shots="" of="" all="" test="" cases="" (minimum="" of="" 6):="" a.="" 4="" working="" calculations="" (1="" for="" each="" variable).="" b.="" 1="" with="" an="" error="" message.="" c.="" 1="" for="" clear="" windows.="" hints:="" 1.="" you="" can="" use="" the="" isempty()="" command="" to="" determine="" if="" a="" variable="" is="" empty.="" 2.="" determining="" how="" many="" user="" inputs="" have="" been="" provided="" can="" be="" the="" most="" challenging="" portion="" of="" this="" task.="" there="" are="" a="" number="" of="" valid="" approaches,="" but="" here="" is="" a="" hint="" to="" guide="" you="" towards="" what="" could="" be="" a="" better="" solution:="" the="" length="" command="" can="" be="" used="" within="" a="" single="" condition="" to="" evaluate="" whether="" exactly="" 3="" numbers="" have="" been="" provided="" in="" the="" text="" boxes.="" 3.="" use="" conditional="" statements="" to="" select="" the="" proper="" equation.="" if="" you="" know="" that="" there="" are="" exactly="" 3="" inputs,="" then="" there="" are="" only="" 4="" other="" possible="" situations="" (missing="" a,="" i,="" n,="" or="" p)="" and="" that="" equation="" should="" be="" used.="" 4.="" you="" may="" need="" to="" use="" some="" debugging="" techniques="" to="" make="" your="" code="" work="" properly.="" in="" order="" to="" detect="" errors,="" consider:="" a.="" using="" the="" debugger="" with="" breakpoints="" set="" within="" the="" suspected="" callback.="" b.="" temporarily="" un-suppressing="" certain="" lines="" of="" code.="" c.="" making="" extra="" displays="" on="" the="">
Answered Same DayMar 14, 2021

Answer To: Application 8: Loan Calculator GUI ENGR 1221 Designed to test skills with: GUIs, user-defined...

Kshitij answered on Mar 19 2021
138 Votes
newgui/Acal.m
p=399.25;
I=0.005;
N=48;
A=(p/I)*(1-(1+I)^-N)
newgui/cal.m
I=.005;
A=17000;
p=399.25;
w=(1-((I*A)/p));
r=1+I;
q=log10(w);
s=log10(r);
%%
N=real(-q/s);
newgui/Functions Created.pdf
Functions Created-
For Acal calculation
Cal.m
P calculating
Inew calculation using newton Rapson
GUI Crea
ted-
newgui/loancalculator.fig
newgui/loancalculator.m
function varargout = loancalculator(varargin)
% LOANCALCULATOR MATLAB code for loancalculator.fig
% LOANCALCULATOR, by itself, creates a new LOANCALCULATOR or raises the existing
% singleton*.
%
% H = LOANCALCULATOR returns the handle to a new LOANCALCULATOR or the handle to
% the existing singleton*.
%
% LOANCALCULATOR('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in LOANCALCULATOR.M with the given input arguments.
%
% LOANCALCULATOR('Property','Value',...) creates a new LOANCALCULATOR or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before loancalculator_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to loancalculator_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help loancalculator
% Last Modified by GUIDE v2.5 19-Mar-2019 12:04:44
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @loancalculator_OpeningFcn, ...
'gui_OutputFcn', @loancalculator_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before loancalculator is made visible.
function loancalculator_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to loancalculator (see VARARGIN)
% Choose default command line output for loancalculator
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes loancalculator wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = loancalculator_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here