1  // A test application to show how to use the AccountException class.
  2  // This application catches an exception thrown by the other class.
  3  //
  4  //     AccountTestException  ----uses---->   AccountException
  5  //
  6  
  7  
  8  public class AccountTestException
  9  { 
 10    static AccountException deanna;    // variable for instance of Account class
 11  
 12    public static void main(String[] args)
 13    {
 14      double interest;
 15  
 16      // create a new instance of the AccountCmp class
 17      deanna = new AccountException ("Deanna", 5000. );
 18    
 19  
 20      System.out.println("Deanna's Bank Account         Balance");
 21      System.out.println("Initial balance is            $" 
 22                   + deanna.getbalance());
 23  
 24      // call an Account method on the instance deanna
 25      deanna.deposit(1500.);
 26      System.out.println("Deposits $1500.               $"
 27                   + deanna.getbalance());
 28  
 29      try
 30        { deanna.withdraw(523.);
 31          System.out.println("Attempt to withdraw $523.     $"
 32                   + deanna.getbalance());
 33        }
 34        catch (Exception e)
 35        {System.out.println("Attempt to withdraw $523.      "
 36                   + e.getMessage());}
 37  
 38      try
 39        { deanna.withdraw(7000.);
 40          System.out.println("Attempt to withdraw $7000.     $"
 41                   + deanna.getbalance());
 42        }
 43        catch (Exception e)
 44        {System.out.println("Attempt to withdraw $7000.      "
 45                   + e.getMessage());}
 46  
 47      interest = deanna.monthactivity();
 48      System.out.println("After one month, interest $"
 49  	       + interest);
 50      System.out.println("End of the month              $"
 51                   + deanna.getbalance());
 52    }
 53  }
 54  
 55  
 56