100 import javax.swing.JFrame; 11 import javax.swing. JOptionPane; 13 public class Applications extends JFrame { public static...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
100 import javax.swing.JFrame; 11 import javax.swing. JOptionPane; 13 public class Applications extends JFrame { public static void main(String[] args) { Account acc = null; ATM atm = null; SFSCHNACKDNP8555550558 22 | 33 34 35 36 37 38 39 $40 41 42 43 44 45 46 47 48 49 $50 51 52 53 54 55 56 57 58 59 60 61 62 boolean client = true; boolean transaction Required = true; Applications app = new Applications(); // ask the user if they want to open an account, output will depends on their answer // if yes will continue the program, if either cancel or no will close the program while(client) { int result = JOptionPane.showConfirmDialog( app, "Would you like to open an account? " + "The minimum deposit is 100 dollars. " + "If you have an account please click Cancel", "Client Window", JOptionPane. YES_NO_CANCEL_OPTION, JOptionPane. QUESTION_MESSAGE ); if(result JOptionPane.YES_OPTION) { acc = new Account (); atm = new ATM (acc); } else if(result == JOptionPane.NO_OPTION) { client = false; } else if(result == JOptionPane.CANCEL_OPTION) { if(acc != null) { } == atm = new ATM(acc); transaction Required = true; while(transactionRequired) { int yesNo = JOptionPane.showConfirmDialog( app, "Please click Yes for a transaction Click No to exit current process.", "Client Window", JOptionPane. YES_NO_OPTION, ); JOptionPane.QUESTION_MESSAGE if(yesNo== JOptionPane.YES_OPTION) { atm. transaction(); } } else { } else if(yesNo== JOptionPane.NO_OPTION) { transactionRequired = false; } JOptionPane.showMessageDialog(app, "Sorry, you do not have an account.", "Client Window", JOptionPane. ERROR_MESSAGE); client = false; *Account.java 100 import java.util.Scanner; 11 import javax.swing.JFrame; 12 import javax.swing. JOptionPane; 13 14 public class ATM extends JFrame { 15 16 17 18 190 20 21 22 23 24 25 26 270 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 (3 *Applications.java private Account acc; private Scanner keyboard; public ATM(Account account) { this.acc = account; this.keyboard = new Scanner(System.in); transaction(); } // ask to enter the PIN code that was given to the user before, if correct will continue the program // otherwise will stop and ask you again public void transaction() { System.out.println("Please enter your PIN code here: "); int pin = keyboard.nextInt (); ); ATM.java X // ask either want to withdraw or deposit, or maybe you can use W for withdraw, D for deposit if(acc.getPin() == pin) { String input = (String) JOptionPane.showInput Dialog( rootPane, "Please enter W or w to withdraw Enter D or d for deposit", "Input", JOptionPane. QUESTION_MESSAGE, null, null, 1111 if(input.equalsIgnoreCase("w")) { String withdrawStr = (String) JOptionPane.showInputDialog( rootPane, "Please enter the amount you want to withdraw", "Input", JOptionPane.QUESTION_MESSAGE, null, null, 11 11 ); double withdrawValue = Double.valueOf(withdrawStr); this.acc.withdraw(withdrawValue); this.acc.showBalance(); // tell the user that we accept only the following bills, if enter the available bills will continue // otherwise will end the program } else if (input.equalsIgnoreCase("d")) { JOptionPane.showMessageDialog(rootPane, "We accept the following dollar bills: " + "1, 5, 10, 20, 50, 100 " + "Please insert the bill on the console " + "Enter any other number to stop depositing", "Message", JOptionPane. INFORMATION_MESSAGE); *Account.java J 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84} *Applications.java ATM.java X 17 USK Cacher ware wame co CO WECHIMI un vi exposic, or mayor you can use it for WeCharaw, for acposic if(acc.getPin() == pin) { String input = (String) JOptionPane.showInput Dialog( rootPane, "Please enter W or w to withdraw Enter D or d for deposit", "Input", } ); JOptionPane.QUESTION_MESSAGE, null, null, 1111 if(input.equals IgnoreCase("w")) { String withdrawStr = (String) JOptionPane.showInputDialog( rootPane, "Please enter the amount you want to withdraw", "Input", JOptionPane.QUESTION_MESSAGE, null, null, ); double withdrawValue = Double.valueOf(withdrawStr); this.acc.withdraw(withdrawValue); } } else { } this.acc.showBalance(); // tell the user that we accept only the following bills, if enter the available bills will continue // otherwise will end the program } else if (input.equalsIgnoreCase("d")) { JOptionPane.showMessageDialog(rootPane, "1, 5, 10, 20, 50, 100 " + "Please insert the bill on the console " + "Enter any other number to stop depositing", "Message", JOptionPane. INFORMATION_MESSAGE); System.out.println("Enter the bills here:"); double depositValue = 0.0; double lastInput = 0.0; do { "We accept the following dollar bills: " lastInput = keyboard.nextDouble(); if(lastInput == 1 || lastInput % 5 == 0) { depositValue += lastInput; } } while(lastInput == 1 || lastInput % 5 == 0); this.acc.deposit (depositValue); this.acc.showBalance(); System.out.println("Wrong PIN, transaction aborted."); *Account.java X *Applications.java 110 import java.util.Random; 14 15 public class Account extends JFrame { 16 17 18 19 20 21 220 23 24 25 26 27 28 29 30 31 32 33 34 35 36 private double balance; private int pin; *I*328**N*********RARORA BUY //ask the user what is the amount for deposit //give the user the PIN for his account and tell them to take a note of it public Account() { } String balanceStr = (String) JOption Pane.showInputDialog( rootPane, ); } 37 380 public int getPin() { return pin; ATM.java "Please enter the amount for deposit Please take note a PIN code will be issued for you", "Client Window", JOptionPane. WARNING_MESSAGE, null, null, this.balance Double.valueOf (balanceStr); createPin(); JOptionPane.showMessageDialog(rootPane, "Take note of your PIN: " + pin, "Client Window", JOptionPane. WARNING_MESSAGE) ; } = } public void createPin() { if(pin == 0) { pin = new Random() .nextInt(99991000) + 1000; } else { public void setBalance (double balance) { this.balance = balance; } // show the balance of the account public void showBalance() { JOptionPane.showMessageDialog(this, "The current balance is " + String.format("$%.2f", balance), "Message", JOptionPane. INFORMATION_MESSAGE); } public void deposit (double value) { this.balance += value; } public void withdraw(double value) { if(value> balance) { System.out.println("Required amount exceeds balance. You receive your balance."); this.balance -= value; 100 import javax.swing.JFrame; 11 import javax.swing. JOptionPane; 13 public class Applications extends JFrame { public static void main(String[] args) { Account acc = null; ATM atm = null; SFSCHNACKDNP8555550558 22 | 33 34 35 36 37 38 39 $40 41 42 43 44 45 46 47 48 49 $50 51 52 53 54 55 56 57 58 59 60 61 62 boolean client = true; boolean transaction Required = true; Applications app = new Applications(); // ask the user if they want to open an account, output will depends on their answer // if yes will continue the program, if either cancel or no will close the program while(client) { int result = JOptionPane.showConfirmDialog( app, "Would you like to open an account? " + "The minimum deposit is 100 dollars. " + "If you have an account please click Cancel", "Client Window", JOptionPane. YES_NO_CANCEL_OPTION, JOptionPane. QUESTION_MESSAGE ); if(result JOptionPane.YES_OPTION) { acc = new Account (); atm = new ATM (acc); } else if(result == JOptionPane.NO_OPTION) { client = false; } else if(result == JOptionPane.CANCEL_OPTION) { if(acc != null) { } == atm = new ATM(acc); transaction Required = true; while(transactionRequired) { int yesNo = JOptionPane.showConfirmDialog( app, "Please click Yes for a transaction Click No to exit current process.", "Client Window", JOptionPane. YES_NO_OPTION, ); JOptionPane.QUESTION_MESSAGE if(yesNo== JOptionPane.YES_OPTION) { atm. transaction(); } } else { } else if(yesNo== JOptionPane.NO_OPTION) { transactionRequired = false; } JOptionPane.showMessageDialog(app, "Sorry, you do not have an account.", "Client Window", JOptionPane. ERROR_MESSAGE); client = false; *Account.java 100 import java.util.Scanner; 11 import javax.swing.JFrame; 12 import javax.swing. JOptionPane; 13 14 public class ATM extends JFrame { 15 16 17 18 190 20 21 22 23 24 25 26 270 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 (3 *Applications.java private Account acc; private Scanner keyboard; public ATM(Account account) { this.acc = account; this.keyboard = new Scanner(System.in); transaction(); } // ask to enter the PIN code that was given to the user before, if correct will continue the program // otherwise will stop and ask you again public void transaction() { System.out.println("Please enter your PIN code here: "); int pin = keyboard.nextInt (); ); ATM.java X // ask either want to withdraw or deposit, or maybe you can use W for withdraw, D for deposit if(acc.getPin() == pin) { String input = (String) JOptionPane.showInput Dialog( rootPane, "Please enter W or w to withdraw Enter D or d for deposit", "Input", JOptionPane. QUESTION_MESSAGE, null, null, 1111 if(input.equalsIgnoreCase("w")) { String withdrawStr = (String) JOptionPane.showInputDialog( rootPane, "Please enter the amount you want to withdraw", "Input", JOptionPane.QUESTION_MESSAGE, null, null, 11 11 ); double withdrawValue = Double.valueOf(withdrawStr); this.acc.withdraw(withdrawValue); this.acc.showBalance(); // tell the user that we accept only the following bills, if enter the available bills will continue // otherwise will end the program } else if (input.equalsIgnoreCase("d")) { JOptionPane.showMessageDialog(rootPane, "We accept the following dollar bills: " + "1, 5, 10, 20, 50, 100 " + "Please insert the bill on the console " + "Enter any other number to stop depositing", "Message", JOptionPane. INFORMATION_MESSAGE); *Account.java J 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84} *Applications.java ATM.java X 17 USK Cacher ware wame co CO WECHIMI un vi exposic, or mayor you can use it for WeCharaw, for acposic if(acc.getPin() == pin) { String input = (String) JOptionPane.showInput Dialog( rootPane, "Please enter W or w to withdraw Enter D or d for deposit", "Input", } ); JOptionPane.QUESTION_MESSAGE, null, null, 1111 if(input.equals IgnoreCase("w")) { String withdrawStr = (String) JOptionPane.showInputDialog( rootPane, "Please enter the amount you want to withdraw", "Input", JOptionPane.QUESTION_MESSAGE, null, null, ); double withdrawValue = Double.valueOf(withdrawStr); this.acc.withdraw(withdrawValue); } } else { } this.acc.showBalance(); // tell the user that we accept only the following bills, if enter the available bills will continue // otherwise will end the program } else if (input.equalsIgnoreCase("d")) { JOptionPane.showMessageDialog(rootPane, "1, 5, 10, 20, 50, 100 " + "Please insert the bill on the console " + "Enter any other number to stop depositing", "Message", JOptionPane. INFORMATION_MESSAGE); System.out.println("Enter the bills here:"); double depositValue = 0.0; double lastInput = 0.0; do { "We accept the following dollar bills: " lastInput = keyboard.nextDouble(); if(lastInput == 1 || lastInput % 5 == 0) { depositValue += lastInput; } } while(lastInput == 1 || lastInput % 5 == 0); this.acc.deposit (depositValue); this.acc.showBalance(); System.out.println("Wrong PIN, transaction aborted."); *Account.java X *Applications.java 110 import java.util.Random; 14 15 public class Account extends JFrame { 16 17 18 19 20 21 220 23 24 25 26 27 28 29 30 31 32 33 34 35 36 private double balance; private int pin; *I*328**N*********RARORA BUY //ask the user what is the amount for deposit //give the user the PIN for his account and tell them to take a note of it public Account() { } String balanceStr = (String) JOption Pane.showInputDialog( rootPane, ); } 37 380 public int getPin() { return pin; ATM.java "Please enter the amount for deposit Please take note a PIN code will be issued for you", "Client Window", JOptionPane. WARNING_MESSAGE, null, null, this.balance Double.valueOf (balanceStr); createPin(); JOptionPane.showMessageDialog(rootPane, "Take note of your PIN: " + pin, "Client Window", JOptionPane. WARNING_MESSAGE) ; } = } public void createPin() { if(pin == 0) { pin = new Random() .nextInt(99991000) + 1000; } else { public void setBalance (double balance) { this.balance = balance; } // show the balance of the account public void showBalance() { JOptionPane.showMessageDialog(this, "The current balance is " + String.format("$%.2f", balance), "Message", JOptionPane. INFORMATION_MESSAGE); } public void deposit (double value) { this.balance += value; } public void withdraw(double value) { if(value> balance) { System.out.println("Required amount exceeds balance. You receive your balance."); this.balance -= value;
Expert Answer:
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
Rewrite Listing 30.1 to display the output in a text area, as shown in Figure 30.30. Listing a 1b2b3b 4b 5 b6bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 7 8bbbbbbbbbbbbbbbbbbbb 9bb10 16 11 12 13 14...
-
Modify the craps program of Fig. 5.8 to allow wagering. Initialize variable bankBalance to 1000 dollars. Prompt the player to enter a wager. Check that wager is less than or equal to bankBalance, and...
-
In early 2015, the employment-population ratio was increasing while the labor force participation rate remained largely unchanged. Shouldn't both of these data series move in the same direction?...
-
What is the elimination-by-aspects decision rule? Discuss.
-
Set up an appropriate equation and solve. Data are accurate to two significant digits unless greater accuracy is given. Approximately 6.9 million wrecked cars are recycled in two consecutive years....
-
Mr. Jenkins, this is typical question: Do you feel that I have treated you fairly in this interview?
-
Assigned Accounts ReceivableJournal Entries Salen Company finances some of its current operations by assigning accounts receivable to a finance company. On July 1, 2010, it assigned, under guarantee,...
-
4. A pharma company you work for makes jars with cream. It claims that the average amount of cream in a jar is at least 90 g. To prove that claim to the customers you decide to test the claim at a...
-
There is an array A made of N integers. Your task is to choose as many integers from A as possible so that, when they are put in ascending order, all of the differences between all pairs of...
-
Blue Specialty Corporation, Illinols Division For the Year ended December 31, 2022 Revenues Sales revenues Cost of goods sold Gross Margin Operating Expenses Sales commission expense Office supplies...
-
Make program. Draw the curve of y=x+2x+3 and xe[-10, 10].
-
Executive Summary Assignment: "Merger Integration at Bank of America: The TrustWeb Project" Assume the role of Mike Morris preparing for his Monday meeting. Determine what steps Morris should take...
-
A stream of aqueous methanol having 45 mol % CHOH is to be separated into a top product having 96 mol% methanol and a bottom liquid with 4 mol % methanol. The feed at its bubble point and the...
-
Consider the following three vectors in R: V = (a) Show that = (V, V2, V3) is a basis for R. Consider the following four vectors in R4: = 1 --0--0---0--(-)) = 1 -(). -(-9). -0). 0 = V3 = 3 1 1 (b)...
-
The following data is provided for Garcon Company and Pepper Company. Garcon Company Pepper Company Beginning finished goods inventory $ 14,400 $ 19,150 Beginning work in process inventory 14,500...
-
3. We assume an automated server system. It has the number of r resources of the similar type. These resources are shared through three (3) processes of P1, P2, and P3. In addition, we assume that...
-
The Adjusted Trial Balance columns of a 10-column work sheet for Webber Co. follow. Complete the work sheet by extending the account balances into the appropriate financial statement columns and by...
-
Write a program that displays all the numbers from 100 to 1,000, ten per line, that are divisible by 5 and 6. Numbers are separated by exactly one space.
-
The depth-first search algorithm described in Listing 28.8 uses recursion. Design a new algorithm without using recursion. Describe it using pseudocode. Implement it by defining a new class named...
-
Write a program that prompts the user to enter 10 integers and displays all combinations of picking two numbers from the 10.
-
What are the six books of original entry?
-
Show the journal entries necessary to record the following items: 2017 Apr 1 Bought office furniture on credit from Durham Brothers Ltd 1,400. 4 We take goods costing 270 out of the business...
-
You are to show the journal entries necessary to record the following items which occured in 2016: (a) May 1 Bought a motor bike on credit from Lakeside Garage for 5,500. (b) May 3 A debt of 347...
Study smarter with the SolutionInn App