Advance programming lab

mail@pastecode.io avatar
unknown
plain_text
12 days ago
1.3 kB
1
Indexable
Never
public class BankAccount {
    
    private String depositorName;
    private String typeOfAccount;
    private int AccountNumber;
    private double balance;
    public BankAccount()
    {
        depositorName=0;
        typeOfAccount=0;
        AccountNumber=0;
        balance=0;
    }
   public BankAccount(String depositorName,String typeOfAccount,int AccountNumber,double balance )
    {
        this.depositorName=depositorName;
        this.typeOfAccount=typeOfAccount;
        this.AccountNumber=AccountNumber;
        this.balance=balance;
    }
    public void depositAmmount(double ammount)

    {
if(amount>0)
    { 
    balance=balance+ammount;
    System.out.println("Deposited:"+ammount);
    }
    else{
        System.out.println("Ammount must be positive...");
    }
    }
    public void withdrawAmmount(double ammount)
    {
      if(ammount>0&& ammount<=balance)
      {
        balance=balance-ammount;
        System.out.println("withdraw:"+withdraw);
      }
      else
      {
      System.out.println("Invalid withdraw");
      }
    }
public void displayNameAndbalance()
{
    System.out.println("Name:"+depositorName);
    System.out.println("Balance:"+balance);
}    
}
Leave a Comment