CptS 122 – Data Structures
Programming Assignment 6: Basic Bank Application
in C++
Assigned:
Due:
I. Learner
Objectives:
At the conclusion of
this programming assignment, participants should be able to:
II.
Prerequisites:
Before starting
this programming assignment, participants should be able to:
Note: This project
is similar to the Account Class problem provided in your Deitel
and Deitel C How To
Program book (Exercise 16.12). You are to write a basic bank application, in C++, that
allows the user of the application to manually create, modify, and delete bank
accounts. Before you write the application you will need to create a class
called Account. The class Account is used to represent customers'
bank accounts. Your class should include four data members to represent the
account balance (a double), account number (an integer), customer name (a
string), and date the account was opened (a string). Your class should provide
two constructors: one default constructor with no parameters and one constructor
with the initial balance, account number, customer name, and date created as
parameters. The second constructor should check the initial balance. If the
balance is not >= 0, the balance should be set to 0 and an error message
should be displayed.
The class should
provide several member functions. Some of which are described below. Remember
that you will have to think about other appropriate member functions (think
about setter and getter functions!). Member function credit
should add an amount to the current balance and store it back into the balance.
Member function debit should withdraw money from the Account,
modify the balance, and ensure the debit amount does not exceed the Account's
balance. If it does, the balance should be left unmodified and the function
should print an appropriate message. Member function printAccountInfo
should print the current balance, account number, customer name, and date
of the account.
Once you have
designed your Account class. You will need to create the main
bank program. Note that you can create the main bank program in the main
function or you can try to create another class for the main bank program. The main program needs to display a menu for:
1. adding new accounts
2. deleting existing accounts
3. crediting/depositing to an existing account
4. debiting/withdrawing from an existing account
5. displaying information for a single specific account
6. displaying a list of all accounts within the bank
As
with previous assignments, you must return back to your menu screen
after an action has been performed. Options 2, 3, 4, and 5 should
display a sub-menu that allows you to choose which account to perform
the action upon. The number of items in this menu should equal the
number of accounts that currently exist within the bank.
Your
code for this assignment must be robust. Think of designing software
that will be used by other people and consider the ramifications of not
handling erroneous input in an elegant fashion. This list is not
exhaustive, but gives a few examples of the types of things that you
should be doing on these assignments:
1. If an
option such as “delete existing account” is chosen and there are no
accounts in the bank, then a message should appear stating this.
2.
If your submenu for options 2-5 lists N accounts and asks the
user to pick one, then it should not crash if the user picks an invalid
account number. You should display
a message telling the user that the account number is invalid and give
them the option of trying again or returning to the main menu.
3.
Avoid using hard-coded array sizes for lists of items that, in
theory, should be able to grow indefinitely. Doing things like creating
a fixed-size array of 10 accounts and
assuming that you won’t need more than this is bad practice. You know
how to use linked lists, dynamic arrays, and other similar mechanisms at this point that should allow you to
write code for a bank that can take an unlimited number of accounts.
4. Make output clear, informative and readable. Have fun with this
assignment!
IV. Submitting Assignments:
V. Grading Guidelines:
This assignment is
worth 100 points. Your assignment will be evaluated based on a successful
compilation and adherence to the program requirements. We will grade according
to the following criteria: