Bank Transactions - Exception Handling
The program must accept N transactions of a bank account as the input. Each transaction has a character amount. The initial balance of the bank account is Rs. 1000. For each transaction the program must validate the trans transaction based on the following conditions
if the amount to be credited is greater than 10000, then the program must print "Max credit limit exceeded Else t credited to the bank account and the upciated balance must be printed. if the amount to be debited is greater than the account balance then the program must print "Insufficient balance
debited from the bank account and the updated balance must be printed
Your task is to fill in the missing lines of code so that the program runs successfully
Example Input/Output 1:
5
+500
-2000 +2000
14003
-1000
Output
1500
Insufficient balance
3500
Max credit 2500
Explanation
The initial account balance is 1000
transactions credit 500. The updated balance is 1500 2nd transaction: debit 2000 2000 1500, so "Insufficient
unit exceeded
balance is printed
3 transaction credit 2000. The updated balance is 3500. 4 transaction credit 14000 14000 10000 s Max credit limit exceeded" pented
5 transaction debit 1000. The updated balance is 2500
SOLUTION :
JAVA PROGRAM
class MaxCreditLimitExceededException extends Exception{
public MaxCreditLimitExceededException(String S){
super(S);
}
}
class InsufficientBalance extends Exception{
public InsufficientBalance(String S){
super(S);
}
}
**************************************************************
Post a Comment