-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.java
More file actions
41 lines (35 loc) Β· 1.14 KB
/
Account.java
File metadata and controls
41 lines (35 loc) Β· 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
public class Account {
private String accountNumber;
private String holderName;
private double balance;
public Account(String accountNumber, String holderName, double balance) {
this.accountNumber = accountNumber;
this.holderName = holderName;
this.balance = balance;
}
public void deposit(double amount) {
if (amount > 0) {
balance += amount;
System.out.println("β
Deposit successful! New Balance: " + balance);
} else {
System.out.println("β Invalid deposit amount!");
}
}
public void withdraw(double amount) {
if (amount > 0 && amount <= balance) {
balance -= amount;
System.out.println("β
Withdrawal successful! Remaining Balance: " + balance);
} else {
System.out.println("β Insufficient balance or invalid amount!");
}
}
public void checkBalance() {
System.out.println("π° Current Balance: " + balance);
}
public String getAccountNumber() {
return accountNumber;
}
public String getHolderName() {
return holderName;
}
}