home *** CD-ROM | disk | FTP | other *** search
/ Learn Java Now / Learn_Java_Now_Microsoft_1996.iso / JavaNow / Code / Chap07 / BankAccount / App1_7.java < prev    next >
Encoding:
Java Source  |  1996-06-20  |  1.1 KB  |  36 lines

  1. // App1_7 - test out the SavingsAccount and CheckingAccount
  2. //          classes. This version  accumulates interest
  3. //          and performs routine withdrawals from both
  4. //          checking and savings.
  5. import java.io.*;   // this includes the println() function
  6.  
  7. public class App1_7
  8. {
  9.     public static void main(String args[])
  10.     {
  11.         // set the interest rate first - just assume 8%
  12.         BankAccount.Rate(8.0);
  13.  
  14.         // create a savings account and a checking account
  15.         CheckingAccount ca = new CheckingAccount(0.0);
  16.         SavingsAccount sa = new SavingsAccount(0.0);
  17.  
  18.         // for 10 months, deposit $100 in each and then
  19.         // accrue monthly interest and fees
  20.         for (int i = 0; i < 10; i++)
  21.         {
  22.           ca.Deposit(100.0);
  23.           sa.Deposit(100.0);
  24.  
  25.           ca.Monthly();
  26.           sa.Monthly();
  27.  
  28.           System.out.print  (i + " - ");
  29.           System.out.print  (ca.AccountNo() + ":" + 
  30.                              ca.Balance() + ", ");
  31.           System.out.println(sa.AccountNo() + ":" + 
  32.                              sa.Balance());
  33.         }
  34.     }
  35. }
  36.