- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank.java
More file actions
Latest commit
26 lines (21 loc) · 687 Bytes
/
Copy pathBank.java
File metadata and controls
26 lines (21 loc) · 687 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
importjava.util.*;
classInsufficientBalanceExceptionextendsException{
InsufficientBalanceException(Stringstr){
super(str);
}
}
publicclassBank {
publicstaticvoidmain(String[] args) {
Scannerscn = newScanner(System.in);
doublebalance = scn.nextDouble();
doubleamount = scn.nextDouble();
try{
if(amount > balance)
thrownewInsufficientBalanceException("Insufficient balance");
balance -= amount;
System.out.println("Remaining Balance = " + balance);
}catch(Exceptione){
System.out.println(e.getMessage());
}
}
}