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="">= 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.>