The second project involves writing a program that implements an ATM machine

computer science


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.

  •  When the Deposit button is clicked the specified amount should be deposited into the selected account.
  •  Clicking the Transfer button signifies transferring funds to the selected account from the other account.

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


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 ( should be used to

format and document your code. Specifically, the following style guide attributes should be addressed:

  •  Header comments include filename, author, date and brief purpose of the program.
  •  In-line comments used to describe major functionality of the code.
  •  Meaningful variable names and prompts applied.
  •  Class names are written in UpperCamelCase.
  •  Variable names are written in lowerCamelCase.
  •  Constant names are in written in All Capitals.
  •  Braces use K&R style.

Related Questions in computer science category

The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.