class LowBalanceException extends Throwable
{
public String toString()
{
return("Low Balance");
}
}
class TransactionExceededException extends Throwable
{
public String toString()
{
return("Transaction Exceeded");
}
}
class Account
{
void withdraw(double balance, double amount) throws LowBalanceException, TransactionExceededException
{
double bal = balance - amount;
if (bal < 500)
{
throw new LowBalanceException();
}
if (amount > 20000)
{
throw new TransactionExceededException();
}
if (bal >=500 && amount < 20000)
{
System.out.println("New Balance = " + bal);
}
}
}
class Bank
{
public static void main(String ar[])
{
Account a = new Account();
try
{
a.withdraw(20000,1000);
a.withdraw(10000,9700);
a.withdraw(30000,26000);
}
catch(LowBalanceException e1)
{
System.out.println(e1);
}
catch(TransactionExceededException e2)
{
System.out.println(e2);
}
}
}