import javax.swing.*;


public class BankAccount
{
   //======== fields (attributes, members)======
   private String name;
   private String acctNo;
   private double balance;
   private final double MIN_BALANCE = 50;


   /**
     initialize all fields as default values
   */

   public BankAccount()
   {
      name="N/A";
      acctNo="00000";
      balance=0;
    }

    /**
     initialize the  fields
     @param n initializes name
     @param aNo initializes acctNo

   */
    public BankAccount(String n, String aNo)
   { 
      name=n;
      acctNo=aNo;
      balance=0;
    }

     /**
     initialize the  fields
     @param n initializes name
     @param aNo initializes acctNo
     @param bal initializes balance

   */
    public BankAccount(String n, String aNo, double bal)
   { 
      name=n;
      acctNo=aNo;
      balance=bal;
   }

   //====== accessors==========

   public String getName()
   {
      return name;
   }

    public String getAcctNo()
   {
      return acctNo;
   }

    public double getBalance()
   {
      return balance;
   }

   public void setName(String n)
   {
      name=n;
   }


   //==== overloaded methods========
   /**
    withdraw 20 dollars from the account.
   */
   public void withdraw()
   {
     final double WITHRAW_AMT=20;

     if(balance>=WITHRAW_AMT)
      balance-=WITHRAW_AMT;
     else
      System.out.println("Insufficient fund!");

   }

    /**
    withdraw  from the account.
    @param amt  withdraw amount
   */
   public void withdraw(double amt)
   {
     if(balance>=amt)
      balance-=amt;
     else
      System.out.println("Insufficient fund!");

   }

   /* This method is not an overloaded method of the above one
    public void withdraw(double amt). Because they have the same
    parameter list(signature). Although the return data type is 
    different, java doesn't know which one to be called.

    Return data type doesn't count in the methods overloading.

   public double withdraw( double amt)
   {
      if(balance>=amt)
         balance-=amt;
       else
      System.out.println("Insufficient fund!");

      return balance;

   }
   */

   public void deposit()
   {
      final double DEPOSIT_AMT=20;

      balance+=DEPOSIT_AMT;
   }



   public void deposit(double amt)
   {

      balance+=amt;
   }


   public void displayInfo()
   {
      JOptionPane.showMessageDialog(null, "Name: "+name+"\nAccNO: "+acctNo+"\nBalance:"+balance);
   }

}

So, you post a bunch of code and fail to say anything about what your specific problem may be... So, what IS your problem?

good luck writing that demo program. If you wrote that class, I'm sure you can do it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.