CPSC 231: Assignment 5 (Worth 4%)
New Concepts to be applied for the assignment
-
Problem decomposition through the use of
program modules (functions and procedures)
-
One dimensional arrays
Writing a simple banking program
You are to write a program that tracks the
bank accounts for a single bank client. The full version of this program
will track information for a maximum of 4 separate accounts: savings, chequing,
mutual fund (in case you aren't sure what a mutual fund is here is a
link that provides some common definitions although having a precise
definition isn't mandatory to complete this assignment) and credit card.
Also your program will iimplement the common set of banking functions: deposits, withdraws,
transfers between accounts and the display of account information. You should
start by declaring a one-dimensional array of real values
which will be used to
track the banking information for a client. Each array element will be
used to store the balance for one of the four types of accounts. You will have to pass
this array as a parameter to the various procedures and functions in your
program.
Grading: Working submissions
Assignments that receive a 'C+'
After declaring the array, each element will
be initialized to some default starting value (a negative number). You can
assume that accounts can only hold positive values so a negative value indicates
that a particular type of account has not yet been opened. The
program will then display a series of available options to the user in the form
of a menu:
#1 |
(d)eposit money into an account |
2 |
(s)how your balance |
3 |
(t)ransfer money between accounts |
4 |
(w)ithdraw money from an account |
5 |
(o)pen a new account |
6 |
(q)uit program |
Note: Not all of these functions will be
implemented for the 'C+' grade version of the assignment. As you implement
the additional features (described in the section below) you will have the
potential to receive a higher grade. You only need to implement menu
options #2, 5 and 6 for the C+ grade version. You have the choice of
either not showing options that have not yet been implemented or have these
options display some sort of "under construction" or "feature not yet implemented"
message when they've been selected.
Option #2: Show your balance
For each bank account that the client has opened, the program will display
the current balance for each account as well as the total balance for all accounts.
The total balance will be equal to the sum of the savings, chequing and mutual
fund accounts (these three accounts are assets: things that you own) minus the balance for the
credit card account (which is a liability:
something that you owe someone else).
Make sure that you only include in this calculation accounts that have actually
been opened. For example, if the person only opened a savings and chequing
account then the total balance would simply be the sum of these two values
(don't add the negative flag value for accounts that have not yet been opened). Although you do not have to
make your output identical to the one in the sample program it should be neat
and presentable in order for you to get credit for your work.
Option #5: Open a new account.
After the user has selecting this option, the program will check if the
person has already opened the maximum number of accounts. If the person
has already opened four accounts then your program should provide a suitable
error message to the user (e.g., "You have already opened the maximum number of
accounts. For further information please contact one of our banking
representatives at (403)123-4567"). If the person has opened fewer than
four accounts, the program will then prompt the user to indicate which (unopened) account
that he or she wishes to open. Opening account
an will change the
balance from a negative value to zero. The program should not allow the
person to re-open an account that has already opened (especially
for the credit card account because setting it to zero will obviously wipe out
any previous balance). The next time that the user selects menu option #2,
the newly crated account will have it's balance displayed and the balance for the account
will be used to calculate the total overall balance.
Option #6: Quit the program.
Until this option is selected by the user the program will continually loop
and redisplay the main menu. When the user does
select the 'quit' option the loop
stops and the program ends.
Implementing additional capabilities
Implementing each of the features listed
below results in the increase of one letter 'step' (e.g., 'C+' to 'B-').
You can implement the features in any order and in any combination
that you wish although it is likely that you will implement features #1 & 2
prior to implementing feature number 3 and features 4 & 5 prior to implementing
feature number 6 and the features related to the asset
accounts will be likely be implemented before versions for the credit card are
finished. Implementing all six features will yield a grade increase of six steps ('C+' to
'A+').
-
Deposit money into the asset accounts. Implement a
procedure that will allow the user to deposit money into one of the
three asset accounts (savings, chequing or mutual fund). The
procedure will
prompt the user to the enter the value to deposit and perform rudimentary
error checking to ensure that a negative value will not be deposited into the
bank account. Entering a negative value is a signal from the user that
he or she wants to cancel the deposit and the program will then
re-display the
main menu. Entering a positive value will increase the appropriate
account by the amount that was entered by the user and a brief confirmation
message will be displayed (e.g., 'Your money has been deposited into your
mutual fund account') and the program will return to the main menu.
-
Withdraw money from the asset accounts.
Implement a procedure that will allow the user
to take money out of one of the three asset accounts. The
procedure will prompt the user to the enter in the value to withdraw. In a
fashion similar to making deposits, entering a negative value will signal a
cancelling of the current transaction and return the user to the main menu.
However your program must also ensure that the person does
withdraw an amount out of an account that is larger than the current balance
(i.e., the client is not allowed to overdraw any of his or her
accounts!). Your program should show an appropriate error message
if a potential withdraw would result in a negative value (e.g., "You cannot
withdraw $25.00 from your savings account because you only have a current
balance of $20.00") and it will return back to the main menu.
Entering a negative value is a signal from the user that he or she wants to
cancel the deposit and the program will then display the main menu. Once an
acceptable amount has been entered the program will decrease the appropriate
account by this amount and display a brief confirmation message and return to
the main menu.
-
Transferring money between the asset accounts.
This feature will only work if the client has
opened two or more asset accounts. If this is not the case then the
program should politely inform the user that they need more than one account
with the bank in order to conduct an inter-account transfer. If the
person has opened up more than one asset account then the program will prompt
the person to indicate from which account does he or she wish to withdraw
money out of. Again the same error checks described in feature #2 must be
conducted. Next your program will prompt the user to indicate the
account that he or she wishes to transfer the money into which cannot be same
account as the source account. (Again the program will simply return to
the main menu if the source and destination account are identical and it will
return back to the main menu). Once a valid set of values has been
entered from the amount and the source and destination accounts your program should display a brief
confirmation message and return to the main menu.
-
Depositing money into the credit card account.
This feature works in a fashion that is similar
to feature number 1. Because the amount shown is the amount owed
then depositing money into this account will reduce the amount owed (and
the reduced value will be shown the next time that the
credit card balance is displayed).
-
Withdrawing money from the credit card account.
This feature works in a fashion that is similar
to feature number 2 except that withdrawals from the account will increase the
amount owed.
-
Transferring money to/from the credit card account.
This feature works in a fashion that is similar
to feature number 3 except that you need to keep in mind that the asset
accounts show the amount that you own while the credit card account shows the
amount that you owe someone else. Consequently the effect of transfers
has an opposite effect on the credit card account than it would have on the
asset accounts:
|
Transfer from |
Transfer to |
Asset account |
Decrease the
balance |
Increase the
balance |
Credit card account |
Increase the
balance |
Decrease the
balance |
Program modules (procedures and function that must be implemented in the full
version of the program):
- Procedure "initialize": Used to initially set the array elements to
some starting negative values.
- Procedure "openAccount": Allows the user to create new accounts by
setting the starting balance to zero.
- Procedure "displayBalance": Shows the current balance for
each the
account that has been opened by the user
(non-negative balance) as well as an overall balance
for all accounts.
- Procedure "makeDeposit": Allows the user to put money into an
opened account.
- Procedure "makeWithdrawal ": Allows the user to take money out of
an opened account.
- Procedure "makeTransfer": Moves money between two different
accounts.
- Function "hasNoAccounts": Because the program will to repeatedly
check if the user has any accounts opened with the bank before it proceeds
with most of the transactions, the code should not be simply rewritten each
time it is required but instead it should be implemented as a function that
takes a list of the user's bank accounts as a parameter
(i.e., the array) and returns a true
value if the person has no accounts open with the bank and a false value if
the person has at least one account.
How you wish to structure the remainder of your
program is up to you, just make sure that your solution is guided by good design
principles e.g., avoid putting all the code into a single function or procedure
(especially the main procedure), each function or procedure should have a well
defined task that gives it a clear purpose. Some of the other functions or
procedures that you wish to implement include:
- Procedure displayMenu: Shows the a list of the main operations of the
program.
- Function hasMaxAccounts: Returns a true value if the person already has
the maximum number of accounts open, false otherwise.
- Function countAccounts: Returns an integer that is equal to the number of
accounts that the user has opened with the bank.
Grading: Non-working submissions
'D' grade submissions:
The student has invested considerable time
and effort
into the assignment, the program does not fulfill any of the above requirements
but it does compile.
'D-' grade submissions:
The student has invested considerable time
and effort into the assignment, the program does not fulfill any of the above
requirements and it does not compile.
Other submission requirements
-
Good coding style and documentation:
They will play a role in determining your final
grade for this assignment. Your grade can be reduced by a letter step
or more if your submission was implemented using bad style conventions (e.g.,
'A' to 'A-'
for employing poor naming
conventions for identifiers, insufficient documentation, the use of global
variables or non-modular design).
-
Include a README file in your submission: For this assignment
your README file must indicate what grade level has been completed (e.g., A, B or C)
as well as which of the above features have been implemented.
Because this assignment and all the others that follow it will allow you to
choose from a list of features that you wish to implement, it is crucial
that you specify exactly what features that you have actually finished.
Your TA is not responsible for wading through every line of your source code in
order to take note of features that you have implemented but not listed in your
README file. Fulfilling this requirement will allow your marker to quickly determine what he or she must look for
and speed up the marking process.
-
Assignments (source code/dot-p file and the README file) must be electronically
submitted via submit.
In addition a paper print out of all the source code and the README must be handed into the
assignment drop box for the lab that you are registered in (located on the
second floor of the Math Sciences building). Electronically submitting the
assignment allows your marker to run the code in order to quickly determine what
features were implemented. Providing a paper printout makes it easier for
your marker to read and scan through your source code.
Sample Executable
You can run a sample executable called "banking"
which can be found in Unix in the directory: /home/231/assignments/assignment5