CSc 4630/6630 Participation Make-up Assignment

If you did not participate in the feedback for the paper summaries on November 8-10, you can complete this assignment to make up for the participation grade. Also, if you did submit feedback for the paper summaries, but you would like to improve your score, you can complete this assignment to replace it. However, note that if you submit this assignment, it will replace your participation score even if the original score is higher.

Documentation

The first thing in your program should be documentation, just like we did in homework 1. Put comments at the very top of your program, with the same information as in the homework assignments.

Objectives

  1. Practice designing a program.
  2. Practice implementing a program design in MATLAB.
  3. Practice testing a program.
  4. To get familiar with matrices, loops, input/output, conditions (if), and interacting with the user.

Introduction

This assignment is to automatically balance a checkbook. Given a starting balance, a current balance, and matrix of checkbook entries, your program should indicate what entries were processed, and if there appears to be an error.

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.

Assignment

To make the checkbook entries, you will need a matrix. Instead of using a text description, we will use codes. Each entry will take one row of the matrix.

The first number will indicate if the transaction was processed, 0 for no, and 1 for yes. This may be zero initially, and your program can change it as appropriate.

The second number is a code for transaction type. These are:
        check = 1
        deposit = 2
        ATM withdrawal = 3
        interest = 4
A check or ATM withdrawal will be deducted from the amount, while a deposit or interest will be added to it.

The third number indicates the check number. There must be a value here, even if it is 0. If the transaction is not a check, then this value should be ignored.

The last number indicates the amount, without the dollar-sign. All amounts should be positive, though they could be zero (such as a void check).

Create a MATLAB script to assign the data, and create a MATLAB function to determine what has been processed.

For example, suppose that we have the following row.

        0, 3, 0, 100

This indicates that the entry has not been processed (0), that it is an ATM withdrawal (3), that it has check number of 0 (0), and that the amount was 100. If the starting balance is 456.78 and the ending balance is 356.78, then it makes sense that this entry has been processed, i.e. $456.78 - $100.00 = $356.78.

Your program should display to the user each entry, in a decoded form. For example, the output should look like:
Starting balance $456.78
not processed $ 12.34   Check #212
    processed $100.00   ATM withdrawal
    processed $ 0.06   Interest
Ending balance $356.84

Your program should work for all possible input matrices of real values. Make sure that you test it with several different cases. Alert the user (with an "error" command) if there is a problem with the data. The first value must be a 0 or 1. The second value must be an integer from 1 to 4. The third value must be a positive integer. The final value must not be negative.


Turn In Your Work
  1. your source code (hard copy)
  2. the output from an example execution in which you test the correctness of your program (using a script*). Use more if the testing needs it. (hard copy)
  3. Also, e-mail your code to the TA (soft copy). Clearly indicate what this assignment is.

The printouts of the above must be handed in at the start of class. To be considered "on-time", you must e-mail the TA with the final version of your code before the due date, and turn in all of the above on-time. Make sure that your printouts use a monospaced font.


* 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''. Do NOT call your script file ``hmwk1.m'', or it may overwrite your homework! Make sure to keep a backup of your work. Type help diary at the MATLAB prompt for more information.