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

I need the functions such as (variables) of this code to be changed and add comm

ID: 3574509 • Letter: I

Question

I need the functions such as (variables) of this code to be changed and add comments! it is to be displayed in GUI java.

---------------------------------------------------------------------------------

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

@SuppressWarnings("serial")
public class D_loanGui extends JFrame implements ActionListener{
   JLabel lbl=new JLabel("Are you making a payment on your loan",SwingConstants.CENTER);
  
  
   JPanel pnlC=new JPanel();
   JPanel buttons=new JPanel();
  
   JButton y=new JButton("Yes");
   JButton n=new JButton("No");
   public D_loanGui(){
       super("Loan Payment");
       setSize(300,150);
       setDefaultCloseOperation(EXIT_ON_CLOSE);
      
       pnlC.setLayout(new BorderLayout());
       pnlC.add(lbl, BorderLayout.CENTER);
       pnlC.add(buttons, BorderLayout.SOUTH);
      
       buttons.add(y);
       buttons.add(n);
      
       y.addActionListener(this);
       n.addActionListener(this);
      
       add(pnlC);
      
       setVisible(true);
   }
   @Override
   public void actionPerformed(ActionEvent e) {
       if(e.getSource()==y){
           String input=JOptionPane.showInputDialog(new JFrame(), "How much are you paying on your loan?");
           if(input!=null){
               Double res=Double.parseDouble(input);  
               Z_Client.makeLoanPayment(res);
               JOptionPane.showMessageDialog(new JFrame(),Z_Client.displayLoan());
               int selectedOption = JOptionPane.showConfirmDialog(null,
                   "Are you done with your transaction?",
                   "Choose",
                   JOptionPane.YES_NO_OPTION);
               if (selectedOption == JOptionPane.YES_OPTION) {
                   this.dispose();
               }
               else{
                   JOptionPane.showMessageDialog(new JFrame(),"

"+Z_Client.displayCheck()+"
"+Z_Client.displaySav()+"
"+Z_Client.displayLoan()+"

");
               }
           }
       }
       else if(e.getSource()==n){
           this.dispose();
       }
   }  
}

Explanation / Answer

import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; @SuppressWarnings("serial") public class D_loanGui extends JFrame implements ActionListener{ JLabel paymentLabel =new JLabel("Are you making a payment on your loan",SwingConstants.CENTER); JPanel canvasPanel =new JPanel(); JPanel buttons=new JPanel(); JButton yesButton =new JButton("Yes"); JButton noButton =new JButton("No"); public D_loanGui(){ super("Loan Payment"); // setting title of the window to Load Payment setSize(300,150); // setting size of the window setDefaultCloseOperation(EXIT_ON_CLOSE); // setting what should happen when window is closed canvasPanel.setLayout(new BorderLayout()); // setting layout of the display panel to borderLayout canvasPanel.add(paymentLabel, BorderLayout.CENTER); // displaying payment label canvasPanel.add(buttons, BorderLayout.SOUTH); // adding buttons to the layout buttons.add(yesButton); buttons.add(noButton); yesButton.addActionListener(this); // setting an action listener on yesButton noButton.addActionListener(this); // setting an action listener on noButton add(canvasPanel); // adding this panel to the window setVisible(true); // setting the window visible } // this method gets called when yesButton or noButton is clicked @Override public void actionPerformed(ActionEvent e) { if(e.getSource()== yesButton){ // do this when yesButton is clicked String input=JOptionPane.showInputDialog(new JFrame(), "How much are you paying on your loan?"); // show input dialog that takes input if(input!=null){ Double res=Double.parseDouble(input); Z_Client.makeLoanPayment(res); // make the loan payment JOptionPane.showMessageDialog(new JFrame(),Z_Client.displayLoan()); // show message indicating if the customer is done with the transaction. int selectedOption = JOptionPane.showConfirmDialog(null, "Are you done with your transaction?", "Choose", JOptionPane.YES_NO_OPTION); if (selectedOption == JOptionPane.YES_OPTION) { // if yes, close the window.. this.dispose(); } else{ // if no, redo this again JOptionPane.showMessageDialog(new JFrame()," "+Z_Client.displayCheck()+" "+Z_Client.displaySav()+" "+Z_Client.displayLoan()+" "); } } } else if(e.getSource()== noButton){ // do this when yesButton is clicked this.dispose(); // close the window } } }

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