Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Documentation The first thing in your program should be documentation, just like

ID: 3573334 • Letter: D

Question

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

Practice designing a program.

Practice implementing a program design in MATLAB.

Practice testing a program.

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:

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.

Starting balance $456.78 not processed $ 12.34 Check #212 processed $100.00 ATM withdrawal processed $ 0.06 Interest Ending balance $356.84

Explanation / Answer

classdef CheckBalance

prompt = 'Please enter the Starting Balance';

startBal = input(prompt);

prompt = 'Please enter the Current Balance';

currentBal = input(prompt);

prompt = 'Please enter the Check value - 0 for No and 1 for Yes';

transStatus= input(prompt);

prompt = 'Please enter the type of transaction - 1 for check, 2 for deposit, 3 for ATM withdrawal, 4 for interest';

transType = input(prompt);

prompt = 'Please enter the check number';

checkNum = input(prompt);

prompt = 'Please enter the amount';

amount = input(prompt);

disp(['Starting Balance', startBal])

if currentBal < startBal

if transStatus == 1

msg = 'processed';

elseif tranStatus == 0

msg = 'not processed';

else

msg = 'Should be either 0 or 1';

end

if amount > 0

if transType == 1

transTypeMsg = 'Check';

bal = amount;

elseif transType == 3

transTypeMsg = 'ATM Withdrawal';

bal = amount;

elseif transType == 2

transTypeMsg = 'deposit';

bal = startBal + amount;

elseif transType == 4

transTypeMsg = 'interest';

bal = startBal + amount;

else

disp('It should be an integer from 1 to 4')

end

end

disp([msg, bal, transTypeMsg])

disp(['Ending Balance', currentBal])

end

end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote