// A test application to show how to use the AccountException class. // This application catches an exception thrown by the other class. // // AccountTestException ----uses----> AccountException // import java.text.*; public class AccountTestException { static AccountException deanna; // variable for instance of Account class public static void main(String[] args) { double interest; // set up number format NumberFormat nf = NumberFormat.getCurrencyInstance(); // create a new instance of the AccountCmp class deanna = new AccountException ("Deanna", 5000. ); System.out.println("Deanna's Bank Account Balance"); System.out.println("Initial balance is " + nf.format (deanna.getbalance())); // call an Account method on the instance deanna deanna.deposit(1500.); System.out.println("Deposits $1500. " + nf.format (deanna.getbalance())); try { deanna.withdraw(523.); System.out.println("Attempt to withdraw $523. " + nf.format (deanna.getbalance())); deanna.withdraw(7000.); System.out.println("Attempt to withdraw $7000. " + nf.format (deanna.getbalance())); } catch (Exception e) {System.out.println("Attempt to withdraw: " + e.getMessage());} interest = deanna.monthactivity(); System.out.println("After one month, interest " + nf.format (interest)); System.out.println("End of the month " + nf.format (deanna.getbalance())); } }