
#include <iostream>
#include <iomanip>
using namespace std;
#include "account.h"

int
main( )
{
  SavingsAccount save( 500.0 );

  double interest;

  interest = save.compound();
  interest = save.compound();
  save.deposit( 150.0 );
  
  //  Set the output precision so that there are two digits to the right
  //  of the decimal points.
  cout.setf(ios::fixed);  
  cout.precision(2);     

  cout << "\nAfter compounding interest twice and depositing $150,\n"
       << "the savings account balance is $"
       <<  save.get_balance()
       << endl << endl;

  cout << "Trying to withdraw $400:  withdrew $"
       <<  save.withdraw( 400.0 )
       << "  new balance  $"
       << save.get_balance() << endl;

  cout << "Trying to withdraw $400:  withdrew $" << save.withdraw( 400.0 )
       << "  new balance  $" << save.get_balance() << endl;

  CheckingAccount check( 200.0 );

  check.deposit( 200.0 );
  cout << "\n\nChecking account balance is $" << check.get_balance()
       << endl;

  cout << "When writing a check for $350, the account balance is reduced\n"
       << "by $" << check.cash_chk( 350.0 )
       << " leaving a new balance of $" << check.get_balance() << endl;

  cout << "\nWhen writing a check for $150, the account balance is reduced\n"
       << "by $" << check.cash_chk( 150.0 )
       << " leaving a new balance of $" << check.get_balance() << endl;

  check.deposit( 500.0 );
  cout << "\nChecking account balance is $" << check.get_balance()
       << endl;

  cout << "When writing a check for $250, the account balance is reduced\n"
       << "by $" << check.cash_chk( 250.0 )
       << " leaving a new balance of $" << check.get_balance() << endl;


  TimeAccount time_s( 200.0, 7.25 );

  time_s.deposit( 200.0 );
  cout << "\n\nTime account:   balance $" << time_s.get_balance()
       << ";  funds available for withdrawl  $"
       << time_s.get_avail() << endl;
  interest = time_s.compound( );
  interest = time_s.compound( );
  interest = time_s.compound( );
  interest = time_s.compound( );
  cout << "\nAfter compounding 4 times:  balance $" << time_s.get_balance()
       << ";  funds available for withdrawl  $"
       << time_s.get_avail() << endl;
  cout << "\nTrying to withdraw $50:  withdrew  $" << time_s.withdraw( 50.0 )
       << endl;
  cout << "\nTrying to withdraw $100:  withdrew  $" << time_s.withdraw( 100.0 )
       << endl;
  cout << "Final  balance $" << time_s.get_balance()
       << ";  funds available for withdrawl  $"
       << time_s.get_avail() << endl;

  return 0;
}

