

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Instructions and problems for a programming assignment in matlab for engineering 1114 students during spring 2008. The assignment involves creating a script and a function for different problems, including determining the average of an unknown number of grades and creating a simple loan calculator. Students are required to add comments to their code, create flowcharts, and provide sample runs.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


EngE 1114 Spring 2008
HW 13* Programming: While loop *This assignment counts towards your programming average.
General Instructions: For both problem solutions, you must add comments in your code so that someone who types “help
You will need flowchart, listing and sample runs for each problem solution.
It is easiest to create a WORD document and copy and paste your flowchart from VISIO, the listing of your program from your MATLAB editor window, and the output for any sample runs from your MATLAB command window. Please put your paper header on all pages.
You may NOT use any built-in MATLAB functions for this assignment other than trig and inverse trig functions and sqrt. However you will be writing some of your own MATLAB functions as part of this assignment.
Problems: Pay particular attention to whether your algorithm should be programmed as a FUNCTION or a SCRIPT.
PROBLEM 1: Prepare the flowchart and MatLab program (SCRIPT file) for an algorithm that will determine and output the average of an unknown number of grades. You may choose to allow the user to stop the program by entering an invalid grade or by explicitly indicating that there are no more grades to enter. You should also add appropriate code so that if the user starts the program but decides not to enter any grades the program terminates without error. Provide sample output for following input values:
Run 1: No values input Run 2: 98, 77, 56, 72, 65, 87, 83, 92, 74, 79
PROBLEM 2: Loan calculators available on the web will help users evaluate how long it will take them to pay off a loan and how much they will be paying the loan company over the entire life of the loan. The life of the loan starts when the loan is given and ends when the loan balance reaches zero. We will program a simple version of a loan calculator. In this problem, we assume the user is given a one-time cash payment from the loan company. Each month thereafter, 1) the user makes a single fixed payment to the loan company in the middle of each month and 2) the loan company adds a single interest charge on the current value of the loan at the end of the month. This means that the loan amount fluctuates twice a month, decreasing when a payment is made but increasing when the loan company adds interest.
(continued on next page)
EngE 1114 Spring 2008
Prepare the flowchart and MatLab program ( FUNCTION file) for an algorithm that will determine and output:
The function will accept:
Note that the loan starts on the first day of the first month. Recall that payment is made in the middle of each month and interest is added on the last day of each month. So, for each month, when interest is added:
Amount owed after interest is added = (Amount owed before interest is added) × (1+ R/12)
You will need to use a while loop since you don’t know how many payments you will make. A good choice of control variable would be the amount owed on the loan.
Use the following to run your function in the command window: