Programming Techniques

Overview of the problem

You are to develop software for a simple banking situation. In the banking system we have customers who have bank accounts. Customers access those accounts via ATMs, on-line, phone and bank branches. Some of these accesses of those accounts give rise to transactions. We need to model the fact that customers have accounts and that there are transactions on those accounts. Normally a customer might have many accounts but in this assignment we will deal with just a savings account.

OO Modelling

We might model such a scenario using three types of object: one for Customers, one for BankAccounts and another for Transactions. In terms of data required, for Customers assume we need a name, an address and a savings account. An array of Customers should be used. For the savings account assume we require an account number, a balance (amount) and an interest rate. For transactions assume we need an account number the transaction applies to, an amount being transacted and a transaction type (such as Deposit, Withdrawal or Interest ). Details of the transactions are held in a file called “trans.dat”.

Below is a suggested UML type diagram representing the object types (classes):

SavingsAccount
-accNumber int
-balance float
-interestRate float
+setUpAccount(int, float, float) void
+addDeposit(float) void
+subWithdraw(float) void
+addInterest() void
+getBalance() float
+matchAccount(int) bool

Customer
-name string
-address string
-saveAcnt SavingsAccount
+createCust(string, string, int) void
+searchAccounts(int) bool
+applyTrans(char, float) void
+accessAccount(char) void

Transaction
-accountNumber int
-amount float
-transType char
+readRecord(ifstream) void
-findAccount(Customer [], int) int
+process(Customer []) void

As can be seen above, the Customer class includes (is composed of) a savingsAccount object.

The main objective of this system is to process transactions on accounts. You will be
provided with a file of transactions. You should create suitable Customer records and
associated savingsAccounts such that these transactions can be correctly processed.

File structure

Typical data to be found in the file is as follows:
24689
250.00
C
123456
100.00
D

A transaction record is in three parts, firstly an account number, secondly an amount and thirdly a transaction code (C = credit, D = debit, I = add interest). Assume all transactions are valid i.e. generate no errors.

Responsibilities of objects

The Transaction object is responsible for reading the transaction file records, finding the relevant account in the array of customers and applying the transaction. To find the relevant account a matching function within the Customer class can be used. A transaction can be applied by calling a function within the Customer class which in
turn calls a function in the savingsAccount class. See UML modelling above. You may choose to alter the function specifications if required. As indicated above Customer objects provide the access to the accounts including searching.

The savingsAccount objects provide basic operations such as deposit, withdrawal, adding interest, getting a balance and account number matching.

Operation of your program

Your program should read the transaction file and correctly apply the transactions to the customers and their accounts. You should setup an array of Customers to suit the data in the file. Make the balance for all customers initially 0. Assume an interest rate of 5% for add interest type transactions. Your program should produce a balance for all customers on screen first then apply
the transactions and then produce an updated balance on screen for every customer.

trans.dat

246890
250.00
C
123456
100.00
C
123456
0.00
I
937568
1200.00
C
246890
150.00
D
123456
50.00
D
337761
50.60
C
123456
150.00
C
337761
75.00
C
337761
40.00
D
246890
0.00
I
937568
250.00
D
846579
1000.00
C
293567
500.00
C
917355
400.00
C
846579
100.00
D
293567
200.00
D
846579
100.00
D
917355
200.00
D
937568
0.00
I

Leave a Reply

Your email address will not be published. Required fields are marked *