Program 26
Program 26
}
}
class Account
{
double amount;
Account(double a)
{
amount = a;
}
void deposite(double a)
{
amount = amount + a;
System.out.println(a + " rupees deposited.");
System.out.println("New balance is : " + amount);
}
void withdraw(double a)
{
if((amount - a)<0)
{
System.out.println("Attempt to withdraw " + a + " rupees is
failed.");
try
{
throw new MyException();
}
catch(MyException e)
{
System.out.println(e);
}
}
else
{
amount = amount -a;
System.out.println(a + " rupees withdrawn.");
System.out.println("New balance is : " + amount);
}
}
}
Output: