Advertisement
Vladkoheca

BankAccount.java

Nov 22nd, 2024 (edited)
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | Source Code | 0 0
  1. public class BankAccount {
  2.     public String accountNumber;
  3.     public String owner;
  4.     public double balance;
  5.  
  6.     public BankAccount(String accountNumber, String owner, double balance) {
  7.         this.accountNumber = accountNumber;
  8.         this.owner = owner;
  9.         this.balance = balance;
  10.     }
  11.     public void displayInfo(){
  12.         System.out.println("The accountNumber of the bank account is: " + accountNumber);
  13.         System.out.println("The owner of the bank account is: " + owner);
  14.         System.out.println("The balance of the bank account is: " + balance);
  15.     }
  16.     public void deposit(double amount) {
  17.         balance += amount;
  18.         System.out.println("The new balance after the deposit is: " + balance);
  19.     }
  20.     public void withdraw(double amount) {
  21.         if (balance >= amount) {
  22.             balance -= amount;
  23.             System.out.println("The new balance after the withdraw is: " + balance);
  24.         } else {
  25.             System.out.println("Not enough balance!");
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement