Teller Software
CSc 1253: Programming Project # 5
Geaux Tiger Teller Software
Out: 4/5
Due: 4/25 by 11:50 PM
Learning Objectives
* To review modular programming and text file input and output,
* To design and implement a menu-driven program with updates to a database,
* To employ call by reference,
* To use an ordered linear search and an array shift,
* To use string input and output,
* To use an array of structured types,
* To use an array as a formal parameter, and
* To produce a formatted report
Problem Scenario: The Geaux Tiger Bank Louisiana LTD has requested
an interactive program to maintain its computer terminals. Due to Louisiana
Deposit Insurance Corporation's regulations, the bank can have no more
than 1000 customers. The bank needs an application that has the following
functionalities:
1. OPEN ACCOUNT
A new customer opens a bank account with an initial balance no less
than $25.00 and a unique account number that is 10 characters long,
2. CLOSE ACCOUNT
to delete the customer's information from the bank record (this opera-
tion is allowed only if the customer's balance is 0),
3. DEPOSIT
adds an amount to the customer's balance provided the account number
is valid,
4. WITHDRAW
subtracts an amount from the customer's balance provided the account
number is valid,
Duncan
1
Spring 2012
Teller Software
CSc 1253: Programming Project # 5
5. BALANCE INQUIRY
displays the customer's account number, full name (first, middle initial,
lastname), and balance, and generates the following report containing
these details:
Geaux Tiger Bank, Lousiana LTD
Customers Listing
100 Les Miles Dr., Baton Rouge, Louisiana 70802
===========================================================
a/c #
First Name
Last Name
Balance
-----------------------------------------------------------
2011-01-001
Paulynne
George
250.00
2009-02-003
Sarah
LaMaison
-200.17
...
...
.....
.....
===========================================================
1. When your program begins running, if the files acinfo.dbf and acbal.dbf
exist, it reads data from them and stores the data in parallel arrays.
acinfo.dbf consists of the fields account number, last name, first name,
and middle initial. acbal.dbf consists of two fields: account number
and balance. As the data is read from the acinfo.dbf file, your main
function should count the number of records in the file. Note that the
number of records in the file corresponds to the number of account
holders (customers). Your program then closes the files. If the files
do not exist, your program simply sets the count of the number of
customers to 0. All of this should be done in the main function.
2. After this step, your program should display the menu interface for the
program. It does so by calling a function menu() that displays the
following:
/**
* This function displays the program menu below:
*
*
Geaux Tigers Bank ATM
*
========================
*
OPEN AN ACCOUNT......[1]
*
CLOSE AN ACCOUNT.....[2]
*
DEPOSIT..............[3]
*
WITHDRAW.............[4]
*
BALANE INQUIRY.......[5]
*
CUSTOMERS LISTING....[6]
*
EXIT.................[0]
*/
void menu()
Duncan
2
Spring 2012
Teller Software
CSc 1253: Programming Project # 5
3. OPEN ACCOUNT: The user is prompted for a 10-character long string
representing the assigned account number for the account. If the ac-
count number already exists or is not 10-characters long, it should be
rejected and an appropriate error message should be displayed. Once
the account number is validated, the user should be prompted to enter
the first name, last name, middle initial, and initial balance of the ac-
count holder. The initial balance can be no less than $25.00. If it is,
the user should not be allowed to open the account and an appropriate
error message should be displayed. All of this data entry will be done
in the main function. The openAccount function will be called to
add this account to the bank's record.
/**
* This function adds a new record to bankRecord array representing
* data for a new account
* @param acno the account number for the new account
* @param fName the account holder's first name
* @param lName the account holder's last name
* @param midInit the account holder's middle initial
* @param initBal the initial balance of this account
* @param bankRecord an array of account information of all customers
*
indexed by account numbers
* @param numAccs the number of accounts
*/
void openAccount(string acno, string fName, string lName, char midInit,
double initBal, AccountInfo bankRecord[], int& numAccs)
Duncan
3
Spring 2012
Teller Software
CSc 1253: Programming Project # 5
4. CLOSE ACCOUNT: The user is prompted for a 10-character long
string representing the assigned account number for the account. If
the account number does not already exists or is not 10-characters
long, it should be rejected and an appropriate error message should be
displayed. Once the account number is validated, a check should be
done to determine whether the account balance is 0. If the balance is
not 0, the account is not removed and a message indicating that the
account cannot be closed because its balance is not 0 should be dis-
played. If the account number entered is valid and the account balance
is 0, the closeAccount function will be called to remove this account
from the bank's record.
/**
* This function removes all information associated with this account
* from the bankRecord and updates the count of the number of
* accounts that the bank holds.
* @param acno the account number for the new account
* @param bankRecord an array of account information of all customers
*
indexed by account numbers
* @param numAccs the number of accounts
*/
void closeAccount(string acno,AccountInfo bankRecord[], int& numAccs)
5. DEPOSIT: The user is prompted for a 10-character long string repre-
senting the assigned account number for the account. If the account
number does not already exists or is not 10-characters long, it should be
rejected and an appropriate error message should be displayed. Once
the account number is validated, The user should be prompted for the
amount to be deposited. If this amount is not greater than 0, an error
message indicating that the deposit amount has to be at least a penny
should be displayed. If the account number entered is valid and the
amount to be deposited is greater than 0, the deposit function will be
called to update the balance associated with the account.
Duncan
4
Spring 2012
Teller Software
CSc 1253: Programming Project # 5
/**
* This function updates the balance associated with this account
* @param acno the account number for the new account
* @param amount the amount to be deposited
* @param bankRecord an array of account information of all customers
*
indexed by account numbers
* @param numAccs the number of accounts
*/
void deposit(string acno, double amount, AccountInfo bankRecord[], int numAccs)
6. WITHDRAW: The user is prompted for a 10-character long string representing the
assigned account number for the account. If the account number does not already
exists or is not 10-characters long, it should be rejected and an appropriate error
message should be displayed. Once the account number is validated, The user
should be prompted for the amount to be withdrawn. If this amount is not greater
than 0, an error message indicating that the amount to be withdrawn has to be at
least a penny is displayed. If the account number entered is valid and the amount
to be withdrawn is greater than 0, the withdraw function will be called to update
the balance associated with the account.
/**
* This function updates the balance associated with this account;
* if the amount to be withdrawn exceeds the balance, the updated
* balance (previous balance - amount) will be negative. Additionally,
* the customer pays an overdraft penalty. So,
* 1. balance = balance - amount, amount is not more than
*
the previous balance.
* 2. balance = balance - amount - penalty
* The bank charges an overdraft fee of $35.00 for an overdraft
* transaction which is defined in a global constant called
* OVERDRAFT_FEE.
* @param acno the account number for the new account
* @param amount the amount to be withdrawn
* @param bankRecord an array of account information of all customers
*
indexed by account numbers
* @param numAccs the number of accounts
*/
void withdraw(string acno, double amount, AccountInfo bankRecord[], int numAccs)
Duncan
5
Spring 2012
Teller Software
CSc 1253: Programming Project # 5
7. BALANCE INQUIRY: The user is prompted for a 10-character long string repre-
senting the assigned account number for the account. If the account number does
not already exists or is not 10-characters long, it should be rejected and an appro-
priate error message should be displayed. Once the account number is validated,
the inquiry function will be called to display the customer's account number, full
name (first, middle initial, lastname), and balance as shown below:
--------------------------
customer: Jane Q. Doe
A/C #: xxxxxxxxxx
Balance: $xxx.xx
--------------------------
/**
* This function displays the account balance.
* @param acno the account number for the new account
* @param bankRecord an array of account information of all customers
*
indexed by account numbers
* @param numAccs the number of accounts
*/
void inquiry(string acno, const AccountInfo bankRecord[], int numAccs)
8. CUSTOMERS LISTING: This generates a listing of all account holders as shown
in the report at the top of page 2 or prints "** THERE ARE NO ACTIVE AC-
COUNTS ***" if there are none. The customersList function will be called to
generate the listing.
/**
* This function adds a new record to bankRecord array representing
* data for a new account
* @param bankRecord an array of account information of all customers
*
indexed by account numbers
*/
void customersList(const AccountInfo bankRecord[], int numAccs)
9. EXIT: When the user selects this option, both acinfo.dbf and acbal.dbf
should be opened in output mode and overwritten using the contents
of the parallel arrays and the appropriate fields. After they are over-
written, they should then be closed. The EXIT procedure will be done
in the main function.
Duncan
6
Spring 2012
Teller Software
CSc 1253: Programming Project # 5
Additional Requirements
Define AccountInfo as a global structured type (struct) that consists of the
following fields:
acNum:string
firstName:string
midInitial:char
lastName:string
balance:double
Define a global constant OVERDRAFT FEE that is set to 35.00. This con-
stant will be used in the withdraw function when the amount to be withdrawn
exceeds the customer's balance. Also, define a global const MAX CUSTOMERS,
setting its value to 1000, that represents the maximum number of customers
that the bank can have. This constant will be used as the size descriptor
in the declaration of the parallel arrays. You must define and use all the
functions listed above using the specifications given.
You may want to use a switch statement to perform the operations pro-
vided in the menu. Each menu item will be a case in the switch statement.
Your menu should be in a loop which terminates only when the user selects
the EXIT option.
Perform all input/output operations in the main function. As you over-
write the data files when the user chooses the EXIT option, be sure to pre-
serve the format of the files. View the data files after you exit the program in
order to determine whether the files are properly being updated. Execute the
cat command followed by the file name. For example, to view the acbal.dbf
file, execute the command below:
classes> cat acinfo.dbf
Duncan
7
Spring 2012
Teller Software
CSc 1253: Programming Project # 5
You should see the contents of the file acinfo.dbf, if the file exists. Follow the
C++ Coding Style Guidelines we discussed in class. Name your source file
geauxbank.cpp. Your source file must have the following header comments:
/**
* @file filename
* @author your name
* @date 9999-99-99
* Description: describe what the program does.
* Course: CS1253.02
* Logon ID: cs1253xx
* Programming Project #: 5
* Instructor: Duncan
*/
Preparing your workspace and submitting Your Work
1. Logon to the server (classes.csc.lsu.edu) using your logon ID and password.
2. Create a directory prog5 in your home area: mkdir prog5
3. Change to the prog5 directory: cd prog5
4. Edit your program using pico or your favorite editor:
pico geauxbank.cpp
Save your program and exit the editor when you are finished.
5. Compile your program: g++ -o geauxbank geauxbank.cpp
6. Correct any syntax errors you may have. Once your program is free of these errors,
run your program:
geauxbank
7. Make sure that your output is formatted as required by using the cat command,
as described earlier, to view your data files before you run the program and after
you exit the program. Test all the functionalities provided on the menu interface
by running the program several times. Correct all semantic errors as you test the
program.
8. submit your assignment to the grader with the following command:
cs1253 dun/bin/p copy 5
This command copies everything in your prog5 directory.
9. Once p copy is finished, check to see if your files have been submitted:
cs1253 dun/bin/verify 5
10. You may submit your work as many times as you wish once the deadline has not
elapsed. Any submission after the deadline means you will get no credit for this
project.
Duncan
8
Spring 2012
Add New Comment