-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.java
More file actions
34 lines (27 loc) · 787 Bytes
/
Copy pathAccount.java
File metadata and controls
34 lines (27 loc) · 787 Bytes
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
public class Account {
int accNo;
String ownerName;
double balance;
public Account(int accNo, String ownerName, double balance) {
this.accNo = accNo;
this.ownerName = ownerName;
this.balance = balance;
}
public void Withdraw(double amt) throws InsufficientBalanceException {
if (balance - amt < 1000) {
throw new InsufficientBalanceException("Insufficient Balance...!\n"
+ "Your Current Balance is : " + balance + ".");
} else {
balance -= amt;
System.out.println("Withdraw SuccessFully..........!\nRemaning Balance is : " + balance + ".");
}
}
public static void main(String[] args) {
Account acc = new Account(101, "Naoe", 10000);
try {
acc.Withdraw(1000);
} catch (InsufficientBalanceException e) {
System.err.println(e);
}
}
}