class InsufficientFundsException extends Exception { public InsufficientFundsException(String message) { super(message); } } class NegativeAmountException extends Exception { public NegativeAmountException(String message) { super(message); } } class BankAccount { private double balance; public BankAccount(double balance) { this.balance = balance; } public void withdraw(double amount) throws InsufficientFundsException, NegativeAmountException { if (amount < 0) { throw new NegativeAmountException("Amount cannot be negative."); } else if (amount > balance) { throw new InsufficientFundsException("Insufficient funds for this withdrawal."); } else { balance -= amount; System.out.println("Withdrawal successful. New balance: $" + balance); } } public double getBalance() { return balance; } } public class Main { public static void main(String[] args) { BankAccount account = new BankAccount(500); try { account.withdraw(600); // Should throw InsufficientFundsException } catch (InsufficientFundsException | NegativeAmountException e) { System.out.println("Error: " + e.getMessage()); } try { account.withdraw(-50); // Should throw NegativeAmountException } catch (InsufficientFundsException | NegativeAmountException e) { System.out.println("Error: " + e.getMessage()); } try { account.withdraw(100); // Should be successful } catch (InsufficientFundsException | NegativeAmountException e) { System.out.println("Error: " + e.getMessage()); } } }