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

There should be three classes in the program. The first class should define the

ID: 3769998 • Letter: T

Question

There should be three classes in the program. The first class should define the GUI and should be hand-coded and not generated by a GUI generator. 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 twoAccount objects, one for the checking account and another for the savings account.

The second class will be called 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 account. Note that when service charges apply, there must also be sufficient funds to pay for that charge.

The third class is InsufficientFunds, which is a user defined checked exception.

Be sure to follow good programming style, which means making all instance and class variables private, naming all constants and avoiding the duplication of code. Furthermore you must select enough scenarios to completely test the program.

Explanation / Answer

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JRadioButton;
public class Frame2 extends JFrame
{
JPanel pane = new JPanel();
JButton withdraw = new JButton("Withdraw");
Frame1()
{
super("JPrompt Demo"); setBounds(100,100,300,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container con = this.getContentPane();
con.add(pane);
pressme.setMnemonic('P');
pane.add(pressme); pressme.requestFocus();
setVisible(true);
}
public static void main(String args[])
   {new Frame1();}
JPanel pane = new JPanel();
JButton deposite = new JButton("Deposite");
Frame2()
{
super("JPrompt Demo"); setBounds(100,100,300,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container con = this.getContentPane();
con.add(pane);
pressme.setMnemonic('P');
pane.add(pressme); pressme.requestFocus();
setVisible(true);
}
public static void main(String args[]) {new Frame2();}
JPanel pane = new JPanel();
JButton transfer to = new JButton("Transfer to");
Frame3()
{
super("JPrompt Demo"); setBounds(100,100,300,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container con = this.getContentPane();
con.add(pane);
pressme.setMnemonic('P');
pane.add(pressme); pressme.requestFocus();
setVisible(true);
}
public static void main(String args[]) {new Frame3();}
JPanel pane = new JPanel();
JButton balance = new JButton("Balance");
Frame4()
{
super("JPrompt Demo"); setBounds(100,100,300,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container con = this.getContentPane();
con.add(pane);
pressme.setMnemonic('P');
pane.add(pressme); pressme.requestFocus();
setVisible(true);
}
public static void main(String args[]) {new Frame4();}

public class SwingJRadioButtonDemo extends JFrame {

public SwingJRadioButtonDemo() {
super("Swing JRadioButton Demo");

JRadioButton option1 = new JRadioButton("Checking");
JRadioButton option2 = new JRadioButton("Saving");

ButtonGroup group = new ButtonGroup();
group.add(option1);
group.add(option2);
  
setLayout(new FlowLayout());

add(option1);
add(option2);
  
pack();
}

public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {

@Override
public void run() {
new SwingJRadioButtonDemo().setVisible(true);
}
}
}

}

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