You are on page 1of 4

Tutorial Question 2

The application

A small high-street commercial bank wishes to computerise their operations. You are required to
implement their system in Java.

The bank offers current, savings and investments accounts.

Current account information includes an integer account number and customer name. The first current
account opened is number 1000. Each account has an overdraft limit. The overdraft limit can be set
when the account is opened; otherwise the default overdraft limit is zero. No interest is paid on credit
balances. Debit balances (overdrafts) are charged interest at 45% per annum. You may assume that
interest operations are only applied at the end of each month. No interest applies in the period
between the date of closing the account and the end of the previous month. Deposit transactions are
charged a service fee of $2.50 each. Withdrawal transactions are charged a service fee of $5.00 each.

Savings account information includes an integer account number and the customer name. The first
savings account opened has number 2000. Deposit transactions are free. Withdrawal transactions are
charged a service fee of $5.00 each. Savings accounts may not be overdrawn. Interest of 25% per
annum is paid on the current balance. You may assume that interest operations are only applied at the
end of each month. No interest applies in the period between the date of closing the account and the
end of the previous month.

Investment account information includes an integer account number and the customer name. The first
investment account opened has number 3000. Deposit and withdrawal transactions are free.
Customers may make as many deposits as they wish but they may make only a single withdrawal
transaction after which the account is closed. Investment accounts may not be overdrawn. Interest of
35% per annum is paid on the current balance. You may assume that interest operations are only
applied at the end of each month. No interest applies in the period between the date of closing the
account and the end of the previous month.

Question 1

The bank requires Java classes and methods to model their customer accounts.

1.1 Give public classes named CurrentAccount, SavingsAccount and InvestmentAccount together
with whatever additional classes you need to implement bank accounts. Include all the
instance fields required to implement the required design, but include only only the minimum
methods required to implement the operations of the following main() method.

1.2 Give a public class AccountTest containing only a main() method which opens the following
accounts, in order. Immediately after a customer account has been opened you must print its
value to the console in the following format:

Number 1234
Type: Current(or Savings or Investment, as applicable)
Name: Zanamwe Ngonidzashe
Balance: $1200.00
<Blank line>

Page 1 of 4
a. A current account for customer Fred Clinton
b. A current account for customer Brok Monday with an overdraft limit of $200
c. A savings account for customer Wilma Fredstone
d. An investment account for customer Tod Esra [25]

Question 2

The bank wishes to perform the following operations on customer accounts

 Print an account value in the format previously specified


 Deposit an amount into an account
 Withdraw an amount from an account
 Change the overdraft limit on a current account
 Change the current account deposit service fee
 Change the current account withdrawal service fee
 Change the savings account withdrawal service fee
 Close an account(the account balance, whether in credit or debit is transferred to the
bank’s own account )
 Apply interest rate to the current balance of an account (you may assume that this will
only be done at the end of the month)

2.1 Implement these operations as methods in appropriate classes.

2.2 Give a public class AccountTest1 containing only the main() method which implements the
following transactions, in order and prints in the format previously specified the value of each
customer account to the console after each transaction:

a. open current account for Fred Flintstone


b. open a savings account for Barney Rubble
c. open an investment account for Wilma Flintstone
d. deposit $2000 in Fred Flintstone’s current account
e. deposit $3000 in Barney Rubble’s savings account
f. deposit $5000 in Wilma Flintstone’s investment account
g. withdraw $400 from Fred Flintstone’s current account
h. deposit $800 in Fred Flintstone’s current account
i. apply interest to Fred Flintstone’s current account
j. withdraw $2300 from Fred Flintstone’s current account
k. close Fred Flintstone’s current account
l. print the bank’s current account value
m. withdraw $2000 from Barney Rubble’s savings account
n. apply interest to Barney Rubble’s savings account
o. withdraw $ 900 from Barney Rubble
p. close Barney Rubble’s savings account
q. print the bank’s own current account value
r. deposit $200 in Wilma Flintstone’s investment account
s. withdraw $600 from Wilma Flintstone’s investment account

Page 2 of 4
t. print the bank’s own current account value

Invalid transactions, such as attempting to withdraw an amount larger than the available balance must
be silently ignored. [30]

Question 3

The bank wishes to store all customer account information in a single ledger. Accounts are stored in
the ledger immediately after they are created, in the order in which they are created. Speed of
operation is irrelevant.

Provide appropriate public classes and methods to implement the ledger as an object of class
ArrayList. You will need to adjust the semantics of some operations described in question 2. For
example, the operation to close an account in question 2 becomes an operation to remove an account
from the ledger. Provide a method to print in the format previously specified the value of each
customer account in the ledger in the order in which they are stored.

Give a public class AccountTest3 containing only main() method which implements the transactions
given in question 2 in order (but do not print account values after each transaction), and print the
complete ledger to the console immediately after transactions c, f, j, k, p and t. The ledger is empty
when your program starts.

Invalid transactions must be silently ignored. [15]

Question 4 [10]

Using Netbeans, develop a desktop application which allows users to calculate the present value or
future value of an amount of money. The application must have text fields which accept the interest
rate, time in years, and the amount of money to be discounted or compounded. The application must
have an additional text field which shall be used for displaying the result. The text fields should be
clearly labelled. Further the application should have two buttons one labelled Future Value and
Present Value. If the Future Value button is clicked the future value must be displayed in the text field
labelled result. If the Present Value button is clicked the present value must be displayed in the text
field labelled result. Your class must be named TValue

Question 5 [10]

a. Write a program that reads the contents of file named infile.java (in the folder named Exam)
and display the contents on the console screen. The class must be named InputFile.
[5]

b. Modify your program so that it reads input from a file named infile.java and output it in
another file named outfile.java which must be in the folder named Exam. The class must be
named OutputFile. [5]

Page 3 of 4
Question 6 [20]

Develop a complete query application for orders and products. The database for the application is
called OrederedProducts and has four relations (attributes for each are shown in brackets) shown
below:

Product (ProductID, Pname, SupplierID, price)

Order (OrderID, OderDate, CustomerID)

Supplier (SupplierID, Sname)

Customer(CustomerID,Cname)

Your application should have predefined queries with an appropriate query for each application
shown in a JComboBox. You should provide the following queries:

i. Select all products from the Product table

ii. Select all orders from the Order table

iii. Select all suppliers from the Supplier table

iv. Select all customers from the Customers table

v. Insert data into each of the four tables

Question 7 [10]

You are given the following marks for each course being done by students in the department of
computer science.

StudentID CT216 CT215 CT210 CT211


1 34 56 70 65
2 45 76 67 64
3 50 70 56 80
4 46 34 56 67
5 53 100 89 98
6 60 89 70 65

Declare a 2 dimensional array and initialise it with the marks in the table above.

Using looping structures print the marks for each student on the same line. After that print a blank line
then print the average mark for each student followed by another blank line then print the lowest mark
for each student. You program should at the same time store the average mark of each student in
another one dimensional array. Lastly the program should calculate and display the average mark for
each course and also store it in a one dimensional array. Don’t use more than two loops.

Page 4 of 4

You might also like