Screenshot 2024-09-09 at 1.21.22 PM
Screenshot 2024-09-09 at 1.21.22 PM
Screenshot 2024-09-09 at 1.21.22 PM
// Constructor
public BankAccount(String accountNumber, String
accountHolderName, double initialBalance) {
this.accountNumber = accountNumber;
this.accountHolderName = accountHolderName;
this.balance = initialBalance;
}
// Deposit method
public void deposit(double amount) {
if (amount > 0) {
balance += amount;
System.out.println("Deposited: " + amount);
} else {
System.out.println("Invalid deposit amount");
}
}
// Withdraw method
public void withdraw(double amount) {
if (amount > 0 && amount <= balance) {
balance -= amount;
System.out.println("Withdrawn: " + amount);
} else {
System.out.println("Insufficient balance or invalid
amount");
}
}