Answer:
public class PostAccount
{
public void withdraw(float savings)
{
if (savings >=0 )
{
IllegalArgumentException exception
= new IllegalArgumentException("Savings cannot be negative");
throw exception;
}
balance = savings - withdraw;
}
}
Step-by-step explanation:
IllgalArgumentException is a type of NumberFormatException of runtime exception. Here in the program we have created an object of IllgalArgumentException class and after that we have thrown the error to show the condition if it does not satisfy the if condition.