public class Account { private double balance; private int id; private String name; public Account(double balance, int id, String name) { this.balance = balance; this.id = id; this.name = name; } public double withdraw(double amount) throws InsufficientFundsException, NegativeAmountException { if (amount < 0) { throw new NegativeAmountException(amount, this, "You can not specify a negative amount to withdraw."); } if (amount > balance) { throw new InsufficientFundsException(amount, this, "Insufficient Funds for a Withdrawal"); } balance = balance - amount; return amount; } public String toString() { return "Name: " + name + " id: " + id + " balance: " + balance; } public static void main(String[] args) { Account account = new Account(100000.00, 1234, "Bob"); try { account.withdraw(1000000.00); } catch (Exception e) { e.printStackTrace(); } try { System.out.println("\nEnter an amount to withdraw:"); double amount = UserInput.readDouble(); account.withdraw(amount); } catch (NumberFormatException e) { System.out.println("You must enter a number!"); System.out.println(e.getMessage()); } catch (InsufficientFundsException e) { System.out.println("You do not have sufficient funds"); System.out.println(e.getMessage()); } catch (NegativeAmountException e) { System.out.println("You can not withdraw a negative amount!"); System.out.println(e.getMessage()); } } } class InsufficientFundsException extends Exception { private double amount; private Account account; public InsufficientFundsException(double amount, Account account, String message) { super(message); this.amount = amount; this.account = account; } public String getMessage() { return super.getMessage() + "\n" + "The attempted withdrawal amount is: " + amount + "\n" + "The account information is: " + account.toString() + "\n"; } } class NegativeAmountException extends Exception { private double amount; private Account account; public NegativeAmountException(double amount, Account account, String message) { super(message); this.amount = amount; this.account = account; } public String getMessage() { return super.getMessage() + "\n" + "The attempted withdrawal amount is: " + amount + "\n" + "The account information is: " + account.toString() + "\n"; } }