1) Develop a Java GUI application that reads account information from a provided text file (list.txt), shows all account numbers in a JComboBox, and displays other GUI controls as shown;
2) Exit button : Quit the application;
3) Deposit button: Make a deposit to a selected account;
4) Withdraw button Make a withdrawal from a selected account;
5) Transfer To button: Make a transfer from a selected account to a beneficiary account.
Bank account application: See image.
GUI in general
Once the program starts, it reads all account information from list.txt (each row in the file is an account record and is in the format of
accountNumber< >customerName< >openDate< >balance
where < > is the partition/delimiter between two fields. The openDate is in the format of year/month/date.) It then displays all account numbers in a JComboBox and shows other GUI controls as in the first figure.
When you select an item (account number) from the JComboBox, the corresponding values for openDate, customerName, and balance will be shown in the three read-only text fields, and the Deposit, Withdraw, and Transfer To buttons becomes enabled, see Fig. 2. See image.
Exit
Clicking this button to close the frame and exit the program.
Instead of using mouse to click the button, pressing Alt + x will also trigger the Exit button. Refer Java API and use setMnemonic() method for this feature.
Deposit
(After selecting an account from the JComboBox), clicking the Deposit button will popup a window as shown in Fig. 3 asking you to enter a deposit amount for the selected account. Hint: refer to JOptionPane.showInputDialog() method for how to create an input dialog like the Fig. 3. See image.
If you enter a non-negative number, such as 100, the amount will be deposited to the account.
See Fig 4: the balanced is adjusted accordingly (from $46.10 to $146.10). The list.txt file should also be updated accordingly as well. See image.
If you clicking Cancel in Fig. 3, the deposit will not occur.
If an invalid deposit amount is entered, such as -100 or $100, you will see an error message as shown in Fig 5. See image.
Withdraw
(After selecting an account from the JComboBox), clicking the Withdraw button will popup a window as shown in Fig. 6 asking you to enter a withdrawal amount for the selected account. See image.
After you enter a non-negative number, such as 100, and if the balance is sufficient, the withdrawal will be made from the account successfully. See Fig. 7, the balanced is adjusted (from $146.10 to $46.10). The list.txt file should also be updated accordingly as well. See image.
If you clicking Cancel in Fig. 6, the withdrawal will not occur.
If an invalid withdrawal amount is entered, such as -100 or $100, you will see an error message as shown in Fig 8. See image.
Transfer To
(After selecting an account from the JComboBox), clicking the Transfer To button will popup a window as shown in Fig. 10 asking you to enter a beneficiary account number. See image.
If a valid account number (any number existing in the JComboBox) is entered, after click OK button, a window like Fig. 11 pops up asking for amount to transfer. See image.
If a valid amount is entered, and the balance is not less than the amount and sometimes the sum of the amount and a transfer fee, the transfer will be succeeded as shown in Fig. 12 and 13. Transfer fee is only applied to account with the balance less than $10000 which is specified in AccountConstants interface (more about AccountConstants see end of this document). See image. See figure 13 image.
If an invalid beneficiary account number (which does not exist in the JComboBox) is entered in Fig. 10, Fig. 14 shows the error message. See image.
If balance is not sufficient for the transfer amount, Fig. 15 shows the error message. See image.
If balance is not sufficient for the transfer amount and transfer fee (when such a fee applies), Fig. 16 shows the error message. See image.
You must have at least the following five classes:
AccountConstants contains two constants, CHECKING_BALANCE_THRESHOLD (value is 10000) and TRANSFER_FEE (value is 2.0). For this project, the business rule is as follows:
When making a transfer to a beneficiary account, if the balance of the transferring account is less than CHECKING_BALANCE_THRESHOLD, TRANSFER_FEE is deducted from the balance after the transfer is made. If the balance is not sufficient to cover both CHECKING_BALANCE_THRESHOLD and TRANSFER_FEE (if the fee applies), the transfer should not be made. If the balance of transferring account is not less than CHECKING_BALANCE_THRESHOLD, TRANSFER_FEE is waived for a transfer.
Account transferTo method in Account is abstract. deposit() and withdraw() are not abstract. If you need, feel free to define other methods, such as getBalance(), in the Account class. See image.
CheckingAccount: extends Account and implements transferTo method. The returned value of transferTo method is defined as follows.
AccountUtility reads list.txt file, updates the file, and provides data for other programs.
AccountApp is the only Java program having the main method.