1. Specification
The second project involves writing a program that implements an ATM machine. The interface to the program
should be a Java Swing GUI that looks similar to the following:
The program should consist of three classes.
1. The first class P2GUI should define the GUI and should be hand-coded and not generated by a GUI generator.
Class P2GUI must contain two Account objects, one for the checking account and another for the savings account.
In addition to the main method and a constructor to build the GUI, event handlers will be needed to handle each
of the four buttons shown above.
When the Withdraw button is clicked, an attempt to withdraw the funds is made from the account
selected by the radio buttons. The attempt might result in an exception being thrown for insufficient
funds. In this situation, a JOptionPane window should be displayed explaining the error.
The transferred amount should be multiple of 10 dollars. The attempt might result in an exception being
thrown for insufficient funds. In case of any error involving the transfer operation, a JOptionPane should
be displayed explaining the error.
Clicking the Balance button will cause a JOptionPane to be displayed showing the current balance in the
selected account.
Besides the specific checks indicated for each operation, the program should also check that all user inputted
amounts are valid numeric values. Also, as a result of successful execution of the Withdraw, Deposit and Transfer
operations, an acknowledge message will be displayed in a JOptionPane window.
2. The second class is the Account. It must have a constructor with one parameter representing the initial deposit plus
four methods that correspond to each of the four buttons in the GUI. It must also incorporate logic to deduct a
service charge of $1.25 when five total withdrawals are made from either account. Note that this means, for
example, if two withdrawals are made from the checking and two from the savings, any withdrawal from either
account thereafter incurs the service charge. After the charge, the counter of withdrawals is reset. The methods
that perform the withdrawals and transfers must throw an InsufficientFunds exception whenever an attempt is
2
made to withdraw or transfer more funds than are available in the account. Note that when service charges apply,
there must also be sufficient funds to pay for that charge.
3. The third class is InsufficientFunds, which is a user-defined checked exception.
Your program should compile without errors.
The Google recommended Java style guide (https://google.github.io/styleguide/javaguide.html) should be used to
format and document your code. Specifically, the following style guide attributes should be addressed:
Get Free Quote!
352 Experts Online