You are on page 1of 3

Java Practical Test 1

Please submit on or before 12 noon. After 12 the platform automatically locks and you will not
be able to submit.
Please on submit working code, if you submit code which is not compiling you get a zero and its
even wiser not to submit if your code is not compiling.
Please read and follow instructions especially on naming classes and files. If files are not named
correctly, you get a zero.
The test is open book but not group work.
Put all your classes in one file preferably Textpad and then run your code and ensure its running
before submitting. Once again, if the code is not running do not submit.
You are encouraged to use Textpad and not IDEs and if you decide to use IDEs make sure there
are no package statements in the file.
When you are done and are sure that your code is running rename your file and add a .txt
extension at the end of the file, your file submission must be named as for example:
r0020219_zanamwe_ngonidzashe.java.txt

A small microfinance institution called New Times would like to automate its operations. The
microfinance is offering several services some of include lending money to clients. These clients should
have accounts with the bank. There are two main types of accounts being operated by the microfinance
namely mobile and nonmobile account. Each account has two attributes namely date of opening, type
of account (mobile or nonmobile) and balance. A mobile account has mobile number which
automatically increments when a new account is created. When a mobile account is opened, an initial
deposit of 5usd or 2500rtgs is required and should be deposited into the account even though the account
allows depositing more than the initial deposit. A nonmobile account has an account number which
automatically increments when a new account is created. When a nonmobile account is opened, an
initial deposit of 15usd or 7500rtgs is required and should be deposited into the account even though
the account allows depositing more than the initial deposit. Each time an account holder makes a deposit
the balance for his/her account is increased AND the balance for the New Times account is reduced.
Each time an account holder makes a withdrawal the balance for his/her account is reduced AND the
balance for the New Times account is increased. Withdrawals are charged a 2% tax on the amount
withdrawn if they exceed 100USD or 50 000ZWL plus a 1.5% transaction fee on the amount withdrawn.
There are two types of mobile accounts, which are Nostro, and Nonnostro accounts. They both have a
currency attribute, however when a Nostro account is opened the currency is set to USD while for
Nonnostro it is set to ZWL. Transfers are charged a 2% tax on the amount transferred if they exceed
100USD or 50 000ZWL plus a 1.5% transaction fee on the amount transferred. The bank would also
want to allow account holders to request and print to file bank statements and also enquire balances.
Statement requests and balance enquiries are charged a fee of 1USD for Nostro accounts and 500ZWL
for Nonnostro accounts. For all transfers and withdrawals, the system should not allow users to
withdraw money such that the current balance goes below the initial deposit. All the taxes and charges
or transaction fees are deducted from the account holder’s account and then added to the New Times’s
account.

Question 1
The microfinance requires Java classes and methods to model operations.
1.1 Give classes you need to implement microfinance operations. Include all the instance fields
required to implement the required design.
1.2 Give a public class named after your registration number concatenated with your fullname
(surname first) separated with underscores (eg r0020219_zanamwe_ngonidzashe) containing
only a main() method which opens the following accounts, in order. Immediately after an
account has been opened, you must print its values to the console in the following format:
Date of opening: 2022-09-06
Type of account: Mobile or Nonmobile (must print the applicable only)
Balance: $120.00
Mobile number or Account Number (must print the applicable only)
Currency: ZWL /USD (must print the applicable only)
<Blank line>

a. A Nostro account for the New Times microfinance [5]


b. A Nonostro account for the New Times microfinance [5]
c. A Nostro account for customer Fred Flintstone with an initial deposit of USD$ 25.00 [5]
d. A Nonnostro account for customer Barney Rubble [5]
e. A Nostro account for customer Wilma Flintstone with an initial deposit of USD$ 15.00 [5]

Question 2
The microfinance wishes to perform the following operations

 Print an account value in the format previously specified


 Deposit an amount into an account
 Get a loan from the microfinance institution. This entails a transfer of money from the
microfinance’s account into the account of the client. The bank charges the client a 3%
interest on the borrowed amount.
 Pay back a loan entails transferring the money into the microfinance institution’s account
if there is already sufficient money in the account otherwise the client makes a deposit
first then transfer the money.
 Withdraw an amount from an account.
 Transfer money from one account to another given that it is possible to transfer money
from a Nostro account into a Nonnostro account. The user should specify the exchange
rate if money is being transferred between accounts with different currencies.
 Enquire current balance of a given account.
 Change the initial deposit fee
 Save the transaction details of all deposits, withdrawals, transfers, balance enquiries and
bank statement requests in a csv file immediately after each transaction. The csv file must
be named after your registration number and must have the following format:

Current Date Account number/ Mobile number Type of transaction eg deposit Amount Balance

 Generate a bank statement given the start and ending dates. The operation must allow one
to search the account number/mobile number from the file and extract all the transactions
between the start and end dates and save them in .txt file named after your registration
number.
2.1 Implement these operations as methods in appropriate classes.
2.2 Using the same public class defined in part 1.2) above, implement the following transactions,
in order and print in the format previously specified the value of each customer account to the
console after each transaction:
a. deposit $2000 in Fred Flintstone’s Nostro account
b. deposit $3000 in Barney Rubble’s Nonnostro account
c. deposit $5000 in Wilma Flintstone’s Wilma Flintstone account
d. withdraw $400 from Fred Flintstone’s Nostro account
e. deposit $800 in Fred Flintstone’s Nostro account
f. withdraw $2300 from Fred Flintstone’s Nostro account
g. withdraw $2000 from Barney Rubble’s Nonnostro account
h. withdraw $ 900 from Barney Rubble
i. deposit $200 in Wilma Flintstone’s account
j. withdraw $600 from Wilma Flintstone’s account
k. loaned $500 to Fred Flintstone
l. transfer $200 from Wilma Flintstone’s account to Barney Rubble’s account
m. generate the bank statement for Barney Rubble’s Nonnostro account
n. enquire balance for Fred Flintstone’s Nostro account
o. Fred Flintstone paid a loan of $500 plus interest.

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

You might also like