CSc 3610 Programming Assignment #1

The first thing in your program should be documentation, such as:
  % hmwk1.m
  % Author: (Your Name)
  % Account: (your account name)
  % CSc 3610 Program #1
  % Due date: (put the due date here)
  % Description:
  % (Give a brief description of what your program does.)
  % Input:
  % (State what the program inputs are.)
  % Output:
  % (State what the program outputs are.)
  % Usage:
  % (Give an example of how to use your program.)
  % (For example: out = myabs(in); )


  1. Practice designing a program.
  2. Practice implementing a program design in MATLAB.
  3. Practice testing a program.
  4. To get familiar with the programming environment.

Imagine that you get a credit card bill. The minimum payment required is $15. If you always pay the minimum amount, how long will it take to reach a zero balance?

Assume that the interest rate is 1.075% per month, and that the bank calculates interest simply, once a month. To make things easy, assume that the minimum payment required never changes, except for the final payment. That is, if the final amount owed is $7, then the final payment will be $7 instead of $15.

To solve your problem, write a program that reads the necessary information to compute and output the indicated values, as efficiently as possible. Design your program by specifying its behavior, identifying the variables and operations it needs to solve the problem, and then organizing the variables and operations into an algorithm. Then code your design in MATLAB using stepwise translation. Finally, test your program thoroughly.

Your program should input the amount owed and the interest rate. Output this information, describing it briefly. Also output the minimum payment. Your program should report how long it would take to pay off the credit card balance (in years and months), as well as what the total amount paid.

Your program should work for all possible inputs. Make sure that you test it with several different cases. For example, what if the initial amount owed is less than $15? What if it is a million dollars? Your program should end after a reasonable number of iterations. Suppose the amount owed is so much that it would take millions of years to pay back. In this situation, your program should end (after, say, 40 simulated years) with a message informing the user that we have reached the maximum number of iterations, and there is still $X left to pay. Is it possible that the initial amount is so large that the loan would never be repaid? If so, how much is that amount? Include this analysis with your design.

New: Since the TA was not able to get her account set up on time (the password had to be reset), we will turn in this assignment differently than was first announced. E-mail your MATLAB source code to the TA (the TA's e-mail address is : ). Do not e-mail the design, do not e-mail the script/output. Do not CC the instructor in your e-mail. Your e-mail should clearly state who you are, that you are in this class, and what you are e-mailing. This may be the only time this semester that e-mails to the TA will be accepted. Make sure to CC yourself on the e-mail, and bring a printout of the e-mail with you to class (see item 4 below).

Turn In Hard copies of:
  1. your design (behavior, variables, operations, algorithm)
  2. your source code
  3. the output from at least three different executions in which you test the correctness of your program (using a script*). One test should be with $302.45 and monthly interest rate of 1.075%
  4. a copy of your e-mail to the TA
The printouts of the above must be handed in during class. To be considered "on-time", you must turn in all of the above on-time. Make sure that your printouts use a monospaced font.

Due date: September 28, 2006

* A script is short for typescript, where everything typed is saved. This keeps a log of all the input and output. MATLAB provides this capability with the diary command. For example, diary out records all inputs and outputs in a file named ``out''. Type help diary at the MATLAB prompt for more information.