Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java program that acts like an ATM: Using class call \"Account\" simulate an ATM

ID: 3654941 • Letter: J

Question

Java program that acts like an ATM: Using class call "Account" simulate an ATM machine. Create ten accounts in an array with ID 0, 1 ... 9. and with an initial balance of $100. The system prompts the user to enter and ID. If the ID is entered incorrectly, ask the user to enter the correct ID. Once the ID is accepted the main menu is displayed as shown below. Choice 1 = View current balance. Choice 2 = Withdraw Money. Choice 3 = Deposit Money. Choice 4 = Exit the Main Menu. Once you exit, the system will prompt you for your ID again. So once the system starts, it will not stop. This is a introduction to Java class. No GUI needed. All is by command line. Thanks! Enter an ID: 4 [Enter] Main Menu 1: Check Balance 2: Withdraw 3: Deposit 4: Exit Enter a choice: 1 [Enter] The balance is 100.0

Explanation / Answer

import javax.swing.*; import java.awt.event.*; public class SwitchPanels implements ActionListener { JFrame frame = new JFrame (); JPanel panel1 = new JPanel (); JPanel panel2 = new JPanel (); JLabel lbl1 = new JLabel ("panel 1"); JLabel lbl2 = new JLabel ("panel 2"); JButton btn = new JButton ("Click me"); int pane = 0; SwitchPanels () { frame.setSize (100, 100); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); panel1.add (lbl1); panel1.add (btn); frame.getContentPane ().add (panel1); btn.addActionListener (this); frame.setVisible (true); } void packPanel2 () { panel2.add (lbl2); panel2.add (btn); } public void actionPerformed (ActionEvent e) { if (e.getSource () == btn) { if (pane == 0) { pane++; frame.getContentPane ().remove (panel1); packPanel2 (); frame.getContentPane ().add (panel2); frame.validate (); } } } public static void main (String[] args) { SwitchPanels con = new SwitchPanels (); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote