File size: 620 Bytes
c574d3a |
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 |
package isufficientbalanceexception;
/**
*
* @author DeLL
*/
public class BankAccount {
double amount;
BankAccount(){
amount=0.0;
}
void deposit(double amt){
amount+=amt;
}
void Withdraw(double wa) throws MyException{
if(amount>=wa){
System.out.println("Withdrawn successful!! Remaining balance is:"+(amount-=wa));
}
else{
double amtrequired=wa-amount;
throw new MyException("Insufficient balance!! your account has"+amtrequired+" rupees less than you want to withdraw!");
}
}
}
|