-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank.java
More file actions
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
import java.util.*;
class InsufficientBalanceException extends Exception{
InsufficientBalanceException(String str){
super(str);
}
}
public class Bank {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
double balance = scn.nextDouble();
double amount = scn.nextDouble();
try{
if(amount > balance)
throw new InsufficientBalanceException("Insufficient balance");
balance -= amount;
System.out.println("Remaining Balance = " + balance);
}catch(Exception e){
System.out.println(e.getMessage());
}
}
}