Starting from:
$35

$29

Project #2 Solution

This project involves writing a program that implements an ATM machine. The interface to the program should be a Java GUI that looks similar to the following:










The program should consist of three classes.




The first class should define the GUI. 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, several checks must be made. The first check is to ensure the value in the text field is numeric. Next a check must be made to ensure the amount is in increments of $20. At that point 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, If any of those three errors occur a



JOptionPane window should be displayed explaining the error. Otherwise a window should be displayed confirming that the withdrawal has succeeded. When the Deposit button is clicked the only necessary check is to ensure that the amount input in the textfield is numeric. Clicking the Transfer button signifies transferring funds to the selected account from the other account. The checks needed are to confirm that the amount supplied is numeric and that there are sufficient funds in the account from which




the funds are being transferred. Clicking the Balance button will cause a JOptionPane window to be displayed showing the current balance in the selected account. The main




class must contain two Account objects, one for the checking account and another for the savings account.




The second class is Account. It must have a constructor plus a method that corresponds to each of the four buttons in the GUI. It must also incorporate logic to deduct a service charge of $1.50 when more than four 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. The method that performs the withdrawals must throw an InsufficientFunds exception whenever an attempt is made to withdraw more funds than are available in the







1




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.




The google recommended Java style guide, provided as link in the week 2 content, 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.




In addition the following design constraints should be followed:




Declare all instance variables private Avoid the duplication of code




Test cases should be supplied in the form of table with columns indicating the input values, expected output, actual output and if the test case passed or failed. This table should contain 4 columns with appropriate labels and a row for each test case. Note that the actual output should be the actual results you receive when running your program and applying the input for the test record. Be sure to select enough different scenarios to completely test the program.




Note: All code should compile and run without issue.




Submission requirements




Deliverables include all Java files (.java) and a single word (or PDF) document. The Java files should be named appropriately for your applications. The word (or PDF) document should include screen captures showing the successful compiling and running of each of the test cases. Each screen capture should be properly labeled clearly indicated what the screen capture represents. The test cases table should be included in your word or PDF document and properly labeled as well.




Submit your files to the Project 2 assignment area no later than the due date listed in your LEO classroom.




You should include your name and P2 in your word (or PDF) file submitted (e.g.




firstnamelastnameP2.docx or firstnamelastnameP2.pdf).








































2







Grading Rubric:




The following grading rubric will be used to determine your grade:




Attribute
Meets
Does not meet
GUI Class
35 points
0 points


Defines the GUI.
Does not define the GUI.


Contains the main method and
Does not contain the main


a constructor to build the GUI.
method and a constructor to




build the GUI.


Contains event handlers to




handle each of the four buttons.
Does not contain event




handlers to handle each of the


Contains Withdrawal checks to
four buttons.


ensure the value in the text field




is numeric.
Does not contain Withdrawal




checks to ensure the value in


Contains Withdrawal checks to
the text field is numeric.


ensure the amount is in




increments of $20.
Does not contain Withdrawal




checks to ensure the amount is


Provides ability to attempt to
in increments of $20.


withdraw the funds is made




from the account selected by
Does not provide ability to


the radio buttons.
attempt to withdraw the funds




is made from the account


An exception is thrown for
selected by the radio buttons.


insufficient funds, or if value is




not numeric or is value is not in
An exception is not thrown for


$20 increment using a
insufficient funds, or if value is


JOptionPane window explaining
not numeric or is value is not in


the error.
$20 increment using a




JOptionPane window explaining


Upon successful withdrawal, a
the error.


window is displayed confirming




that the withdrawal has
Upon successful withdrawal, a


succeeded.
window is not displayed




confirming that the withdrawal


Provides ability to attempt
has succeeded.


Deposit when Deposit button is




clicked.














3



Contains Deposit checks to
Does not provide ability to


ensure the value in the text field
attempt Deposit when Deposit


is numeric.
button is clicked.


Contains Transfer button
Does not contain Deposit


functionality providing
checks to ensure the value in


transferring funds to the
the text field is numeric.


selected account from the other




account.
Does not contain Transfer




button functionality providing


Contains transfer checks to
transferring funds to the


confirm that the amount
selected account from the other


supplied is numeric and that
account.


there are sufficient funds in the




account from which the funds
Does not contain transfer


are being transferred.
checks to confirm that the




amount supplied is numeric and


Contains a Balance button will
that there are sufficient funds in


cause a JOptionPane window to
the account from which the


be displayed showing the
funds are being transferred.


current balance in the selected




account.
Does not contain a Balance




button will cause a JOptionPane


The main class contains two
window to be displayed


Account objects, one for the
showing the current balance in


checking account and another
the selected account.


for the savings account.






The main class does not contain




two Account objects, one for




the checking account and




another for the savings account.




Code does not Compile.
Account class
25 points
0 points


Contains a constructor plus a
Does not contain a constructor


method that corresponds to
plus a method that corresponds


each of the four buttons in the
to each of the four buttons in


GUI.
the GUI.


Incorporates logic to deduct a
Does not incorporate logic to


service charge of $1.50 when
deduct a service charge of $1.50


more than four total
when more than four total


withdrawals are made from
withdrawals are made from


either account.
either account.















4



The method that performs the
The method that performs the


withdrawals throws an
withdrawals does not throws an


InsufficientFunds exception
InsufficientFunds exception


whenever an attempt is made
whenever an attempt is made


to withdraw more funds than
to withdraw more funds than


are available in the account.
are available in the account.


Checks that there must be
Does not check that there must


sufficient funds to pay for
be sufficient funds to pay for


service charge.
service charge.




Code does not Compile.
InsufficientFundsException
20 points
0 points
Class






Is a user defined checked
Is not a user defined checked


exception class.
exception class.


Handles all user-defined
Does not handle all user-


exceptions.
defined exceptions.




Code does not Compile.
Test Cases
10 points
0 points


Test cases are supplied in the
No test cases were provided.


form of table with columns




indicating the input values,




expected output, actual output




and if the test case passed or




failed.




Enough scenarios selected to




completely test the program.




Test cases were included in the




supporting word or PDF




documentation.


Documentation and Style guide
10 points
0 points


Screen captures were provided
No documentation included.


and labeled for compiling your




code, and running each of your
Java style guide was not used to


test cases.
prepare the Java code.


Header comments include
All instance variables not


filename, author, date and brief
declared private.


purpose of the program.












5


In-line comments used to
Duplication of code was not


describe major functionality of
avoided.


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.




Declare all instance variables




private.




Avoids the duplication of code.











































































































6

More products