Question
Project must be done in NetBeans 8.2 in Java with code compiled and screen shots Project 2 This project involves writing a program that implements
Project must be done in NetBeans 8.2 in Java with code compiled and screen shots
Project 2 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. 1. 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. 2. 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 2 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).
Project 2 Expectations
Please review General Programming Expectations document located in Week 2 under Week 2 Checklist.
Obtaining data for Assignment 2
For Project 2, the assignment does not suggest a way of obtaining data for processing. There is a normal assumption that the programmer will generate several instances of the class and pass in a set of hard-coded values as arguments. There are two ways of obtaining the data for this program. The program can either (1) use a two-dimensional array with a set of initialized values or (2) a data file with the data being read into the program and then assigned into a two-dimensional array. Since there are various data types in the array row, you need to determine that best data type declaration for the array. Either way, a data file is supplied for this assignment to make it easier to test the programs among the members of this course and for the instructor to run the program for feedback and grading. The file to use with this program is PRJ2Accounts.txt; this file was created for this specific course. It is expected that you will use this file. The following is the data in the file that can also be used to initialize the two-dimensional array:
7623, S, Jones, Phyllis, 2000.00, 0
7623, C, Jones, Phyllis, 1200.00, 2
8729, S, Smith, Cletus, 1000.00, 1
8729, C, Smith, Cletus, 1700.00, 0
7321, S, Booth, Betty, 4500.00, 2
3242, C, Seybright, Sam, 4612.00, 0
3242, S, Seybright, Sam, 100.00, 3
9823, S, Blu, Oscar, 234.00, 2
9823, C, Blu, Oscar, 2345.00, 0
2341, S, Grief, Sally, 12373.12, 1
2341, C, Grief, Sally, 5421.12, 2
8321, S, Matchel, Jacques, 2314.00, 0
8321, C, Matchel, Jacques, 56233.00, 0
The fields/columns in the file are
Bank Account Number
Type of Account [S = Savings; C = Checking]
Last Name of Account Holder
First Name of Account Holder
Initial Balance in the Account
Current Number of Transactions
If you chose to use a file to input the data, an additional method can be added to the code as either part of Account Class or an independent method inserted before the main () method. Reading a file and assignment the data into an array was covered in the prior assignment.
Suggested Design for Assignment 2
Here is one skeleton design of this program.
package cmis242.prj2smithx;
[imports here]
public class CMIS242 PRJ2SmithX {
public static Data Manipulation {
[Declare array]
[METHOD: Coding to read in file and assign to array]
[MEHTOD: update the various rows of the array]
[METHOD: Display the output]
} //end public static Data Manipulation
public static class ATM_GUI {
[Constructor (), annual salary, and toString]
} // end public static class ATM_GUI
public static class Accounts {
[Balance, deposit, withdrawal, transfer]
} // end public static class Accounts
public static class Savings extends Accounts {
[Constructor (), insufficient funds, fee, transfer, etc.]
} // end public static class Savings extends Accounts
public static class Checking extends Accounts {
[Constructor (), insufficient funds, multiples, fee, transfer, etc.]]
} // end public static Checking extends Accounts
public static void main (String args[]) {
[Declare instance of class]
[Call to read and assign file]
[Call to display output before any transactions]
[Call class to perform transactions]
[Call to display output after transactions completed]
} // end public static void main (String args []) {
} // end public class CMIS242 PRJ2SmithX
The GUI Class
An example of what the ATM screen should look like the one displayed at the beginning of the assignment in Project 2.pdf. There are two issues with the window as it appears in the document. Because you have a set of accounts, there should be a TextField in the window to enter an account number. The current TextField shown should be considered the entry of the bank account number. Both TextFields should have a label explaining the purpose of the field. The bottom of the window should be like the following display:
Account Number: [TextField window]
Amount of Transaction: [TextField window]
There should be displays for all errors, the balance, and the various transactions. Each display should contain a reference to the account number and type. Use JOptionPane for all these display occurrences. A partial listing of displays using JOptionPane is listed below but may not be all the possibilities.
Accounts 7623 over 4 transactions: $1.50 added to transaction
Withdrawal from 7623 must be in $20.00 multiples
Insufficient funds for withdrawal 7623 Checking; Balance $18.50
Insufficient funds in 7623 Savings; Balance $0.98
The balance for 7623 Savings is $2,000.00
The balance for 7623 Savings after $60.00 withdrawal is $1,940.00
The balance for 7623 Checking after $100.00 deposit is $1,300.00
The balance for 7623 Checking after transfer of $100 to Savings is $1,200.00 and balance for 7623 Savings after transfer of $100.00 from Checking is $2,140.00
When the user wishes to end the program, there should be a button to Exit/End the program. Add an Exit/End buttom to the GUI window.
There are some considerations in designing the program:
When the GUI window first displays only the Balance button should be available for use. Only after an account number is entered and verified as existing should the Deposit, Withdrawal, and Transfer buttons be available for use.
If the account number does not exist, an error message should be displayed. In normal circumstance, the program would ask is a new account should be created. For this assignment this process will not be implemented.
The single TextField is ambiguous. It is assumed that it exists for the number used to change the balance of the various accounts, but then why is there a Balance button. With the set of data provided, there would need to be a way of obtaining an account number to retrieve a balance. Then another field for the transaction needed for the other buttons. The following is the preferred display of elements on the window/panel already reference above:
The TextField currently visible on the window/panel is used to retrieve the account number.
A second TextField should be created to accept a transaction amount.
To the left of the TextField(s) should be a label as suggested above.
There is the possibility of the account holder having only a savings or checking account, therefore when the Transfer function is invoked there could be a problem requiring much coding. For this assignment assume that there are two accounts a savings and a checking for a bank customer.
To use the checkbox for processing, check the appropriate type field related to the account. [The Savings radio button is the default button.]
The checking used for Withdrawal should also apply to Deposit.
For the Insufficient Funds check, assume there is at least one multiple of $20 in the checking account and more than $1.00 in the savings account. Only one multiple is necessary to determine sufficient funds.
When a value is placed in a TextField it is normally a String and needs to be parsed into an integer or double, therefore, the statement ensure . . . the text field is numeric. is confusing. The text field for the transaction amount needs to be a double, so it should be parsed into a double.
If the array is a String data type, then the account number can be checked without parsing.
How to proceed with the accumulation of four withdrawals to impose a fee is not clear. The suggested rules for this requirement of the assignment use the following conditions for coding:
Check the number of withdrawals between the two bank accounts.
Sum the numbers in column 5 of the array for the two rows that relate to the accounts of one bank customer.
If the total withdrawals are less than 4, then process the withdrawal and add one to the appropriate account in column 5.
If the total withdrawals are 4, then add one to the appropriate account in column 5 and deduct a $1.50 from the balance of the appropriate account after the transaction is completed.
To streamline the check of more than four withdrawals, change both numbers in column 5 to a 9 once four is reached and use the 9 for adding the $1.50 rather than add the two accounts. [This is optional.]
The program can have a process that resets the number of withdrawals for each account to zero. [This is optional.]
Expectations When the Program Runs:
When the program begins the process of modifying the accounts, display in the Output Window of the IDE all the records in the array in horizontal order.
7623, S, Jones, Phyllis, 2000.00, 0
7623, C, Jones, Phyllis, 1200.00, 2
8729, S, Smith, Cletus, 1000.00, 1
8729, C, Smith, Cletus, 1700.00, 0
7321, S, Booth, Betty, 4500.00, 2
3242, C, Seybright, Sam, 4612.00, 0
3242, S, Seybright, Sam, 100.00, 3
9823, S, Blu, Oscar, 234.00, 2
9823, C, Blu, Oscar, 2345.00, 0
2341, S, Grief, Sally, 12373.12, 1
2341, C, Grief, Sally, 5421.12, 2
8321, S, Matchel, Jacques, 2314.00, 0
8321, C, Matchel, Jacques, 56233.00, 0
Follow the Test Plan scenarios presented in the matrix to process through the program.
When the user clicks the Exit/End button on the window, a new set of records is displayed in the Output Window of the IDE based on the values currently in the array. [All the changes made during the processing of data through the program run should be reflected in the new display.]
project2.txt
7623, S, Jones, Phyllis, 2000.00, 0 7623, C, Jones, Phyllis, 1200.00, 2 8729, S, Smith, Cletus, 1000.00, 1 8729, C, Smith, Cletus, 1700.00, 0 7321, S, Booth, Betty, 4500.00, 2 3242, C, Seybright, Sam, 4612.00, 0 3242, S, Seybright, Sam, 100.00, 3 9823, S, Blu, Oscar, 234.00, 2 9823, C, Blu, Oscar, 2345.00, 0 2341, S, Grief, Sally, 12373.12, 1 2341, C, Grief, Sally, 5421.12, 2 8321, S, Matchel, Jacues, 2314.00, 0 8321, C, Matchel, Jacues, 56233.00, 0
Example Test Cases
Account Number Test | Step | Event/ Entry | Transaction Amount | Output | Message | Status Pass/Fail |
Test Case 1 | ||||||
6323 | 1 | User Entry | 6323 |
| at Enter Account # (four digits) prompt |
|
| 2 | Request Balance |
| 20000 | at Current Balance prompt |
|
| 3 | User Entry | 500 |
| at Transaction Amount prompt |
|
| 4 | Increase |
| 20500 | The new Balance for Account 6323 is 20500 | Pass |
| 5 | User Entry | 1000 |
| at Transaction Amount prompt |
|
| 6 | Decrease |
| 19500 | The new Balance for Account 6323 is 19500 | Pass |
| 7 | User Entry | 0 |
| at Transaction Amount prompt |
|
| 8 | Decrease |
| 19500 | The new Balance for Account 6323 is 19500 | Pass |
| 9 | User Entry | 5000 |
| at Transaction Amount prompt |
|
| 10 | Increase |
| 24500 | The new Balance for Account 6323 is 24500 | Pass |
| 11 | User Entry | -99 |
| at Transaction Amount prompt |
|
| 12 | Decrease |
| 24599 | The new Balance for Account 6323 is 24599 | Pass |
| 13 | User Entry | 150 |
| at Transaction Amount prompt |
|
| 14 | Increase |
| 24749 | The new Balance for Account 6323 is 24749 | Pass |
| 15 | Click Close X |
|
| [Ends program.] |
|
Account Number Test | Step | Event/ Entry | Transaction Amount | Output | Message | Status Pass/Fail |
Test Case 2 | ||||||
8921 | 1 | User Entry | 8921 |
| at Enter Account # (four digits) prompt |
|
| 2 | Request Balance |
| 2500 | at Current Balance prompt |
|
| 3 | User Entry | 150 |
| at Transaction Amount prompt |
|
| 4 | Decrease |
| 2350 | The new Balance for Account 8921 is 2350 | Pass |
| 5 | User Entry | 1000 |
| at Transaction Amount prompt |
|
| 6 | Increase |
| 3350 | The new Balance for Account 8921 is 3350 | Pass |
| 7 | User Entry | 600 |
| at Transaction Amount prompt |
|
| 8 | Decrease |
| 2750 | The new Balance for Account 8921 is 2750 | Pass |
| 9 | User Entry | 35 |
| at Transaction Amount prompt |
|
| 10 | Increase |
| 2785 | The new Balance for Account 8921 is 2785 | Pass |
| 11 | User Entry | 249 |
| at Transaction Amount prompt |
|
| 12 | Decrease |
| 2536 | The new Balance for Account 8921 is 2536 | Pass |
| 13 | User Entry | 372 |
| at Transaction Amount prompt |
|
| 14 | Increase |
| 2908 | The new Balance for Account 8921 is 2908 | Pass |
| 15 | Click Close X |
|
| [Ends program.] |
|
Account Number Test | Step | Event/ Entry | Transaction Amount | Output | Message | Status Pass/Fail |
Test Case 3 | ||||||
3523 | 1 | User Entry | 3523 |
| at Enter Account # (four digits) prompt |
|
| 2 | Request Balance |
| 320 | at Current Balance prompt |
|
| 3 | User Entry | 500 |
| at Transaction Amount prompt |
|
| 4 | Increase |
| 820 | The new Balance for Account 3523 is 820 | Pass |
| 5 | User Entry | 50 |
| at Transaction Amount prompt |
|
| 6 | Decrease |
| 770 | The new Balance for Account 3523 is 770 | Pass |
9999 | 7 | User Entry | 9999 |
| at Enter Account # (four digits) prompt |
|
| 8 | Request Balance |
| 0 | at Current Balance prompt |
|
|
|
|
|
| Account number does not exist. Please try again. | Pass |
1023 | 9 | User Entry | 1023 |
| at Enter Account # (four digits) prompt |
|
| 10 | Request Balance |
| 3000 | at Current Balance prompt | Pass |
| 11 | User Entry | 525 |
| at Transaction Amount prompt |
|
| 12 | Decrease |
| 2475 | The new Balance for Account 1023 is 2475 | Pass |
| 13 | User Entry | 199 |
| at Transaction Amount prompt |
|
| 14 | Increase |
| 2674 | The new Balance for Account 1023 is 2674 | Pass |
9242 | 15 | User Entry | 9242 |
| at Enter Account # (four digits) prompt |
|
| 16 | Request Balance |
| 400 | at Current Balance prompt | Pass |
| 17 | User Entry | 175 |
| at Transaction Amount prompt |
|
| 18 | Increase |
| 575 | The new Balance for Account 9242 is 575 | Pass |
| 19 | User Entry | 43 |
| at Transaction Amount prompt |
|
| 20 | Increase |
| 532 | The new Balance for Account 9242 is 532 | Pass |
1111 | 21 | User Entry | 1111 |
| at Enter Account # (four digits) prompt |
|
| 22 | Request Balance |
| 0 | at Current Balance prompt |
|
|
|
|
|
| Account number does not exist. Please try again. | Pass |
3523 | 23 | User Entry | 3523 |
| at Enter Account # (four digits) prompt |
|
| 24 | Request Balance |
| 770 | at Current Balance prompt | Pass |
1023 | 25 | User Entry | 1023 |
| at Enter Account # (four digits) prompt |
|
| 26 | Request Balance |
| 2674 | at Current Balance prompt | Pass |
9242 | 27 | User Entry | 9242 |
| at Enter Account # (four digits) prompt |
|
| 28 | Request Balance |
| 532 | at Current Balance prompt | Pass |
| 29 | Click Close X |
|
| [Ends program.] |
|
Pic of Test Case
?? ? C oeUesHaroods Frojet2.pd ATM Machine Withdravw Deposit Transfer to Balance ? Checking O Savings ?? ? C oeUesHaroods Frojet2.pd ATM Machine Withdravw Deposit Transfer to Balance ? Checking O Savings
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started