- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomerAccount.java
More file actions
Latest commit
32 lines (28 loc) · 792 Bytes
/
Copy pathCustomerAccount.java
File metadata and controls
32 lines (28 loc) · 792 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
packageexceptionHandling;
classHighBalanceExceptionextendsException{
privatestaticfinallongserialVersionUID = 1L;
publicHighBalanceException() {
super("Customer Balance is more than limit.");
}
}
classCustomerAccount {
privateintacctNum;
privatedoublebalance;
publicstaticfinaldoubleHIGH_CREDIT_LIMIT=2000.00;
publicCustomerAccount(intnum,doublebal) throwsHighBalanceException {
acctNum=num;
balance=bal;
if(balance>HIGH_CREDIT_LIMIT) {
thrownewHighBalanceException();
}
System.out.println("Account Number: "+acctNum+"\nBalance: "+balance);
}
publicstaticvoidmain(String[] args) {
try {
newCustomerAccount(1000211, 3000.00);
}catch(HighBalanceExceptionh){
System.out.println(h.getMessage());
h.getStackTrace();
}
}
}