title: Simple bank account program does not store the balance correctly
body: <p>I'm currently wrapping up my bank account program, but I've ran into some problems en route to completion. The problem seems pretty easy to resolve, but I can't quite wrap my head around how I should go about actually fixing it. </p>
  
  <p>I'll first include the assignment below:</p>
  
  <blockquote>
    <ol>
    <li><p>Implement a class Account. An account has a balance, functions to add and withdraw money, and a function to inquire the current balance. Pass a value into a constructor to set an initial balance. 
    If no value is passed the initial balance should be set to $0. 
    Charge a $5 penalty if an attempt is made to withdraw more money than available in the account. 
    Enhance the Account class to compute interest on the current balance. </p></li>
    <li><p>Implement a class Bank. This bank has two objects, checking and savings, of the type Account that was developed in the preceding exercise. </p></li>
    </ol>
    
    <p>Implement four instance methods:   </p>
    
    <p>deposit(double amount, String account)<br>
    withdraw(double amount, String account)<br>
    transfer(double amount, String account)<br>
    printBalances()</p>
    
    <p>Here the account string is "S" or "C". For the deposit or withdrawal, it indicates which account is affected. For a transfer it indicates the account from which the money is taken; the money is automatically transferred to the other account.</p>
  </blockquote>
  
  <p>The only problem appears to be with actually storing the information for each account in the balance variable in the Account.cpp file. It just stays at 0, and that's why I feel this issue should be easy to fix. I'd imagine I'm just forgetting something very basic about class implementations, but that is why I am here! Now that I think about it, I think part of my confusion comes from the fact that I've implemented similar programs before but used only arrays instead of variables, and I did not experience this same problem. The data seemed to get stored into the array regardless, so this may be my problem? The code follows:</p>
  
  <p>Account.h:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;iomanip&gt;      
  
  using namespace std;
  
  class Account
  {
  public:
      Account();
      Account(double balance);
      void Add(double money);
      void Withdraw(double money);
      double GetBalance();
  
  private:
      double balance; 
  };
  </code></pre>
  
  <p>Account.cpp:</p>
  
  <pre><code>#include "Account.h"
  
  //  Penalty Fee Constant
  const double PENALTY_FEE = 5.00;
  
  Account::Account()
  {
      balance = 0.00;
  }
  
  Account::Account(double money)
  {
      balance = money;
  }
  
  void Account::Add(double money)
  {
      balance += money;
  }
  
  void Account::Withdraw(double money)
  {
      if(money &gt; balance)
          balance += PENALTY_FEE;
      else
          balance -= money;
  }
  
  double Account::GetBalance()
  {
      return balance;
  }
  </code></pre>
  
  <p>Bank.cpp:</p>
  
  <pre><code>#include "Account.h"
  
  void deposit(double, string);
  void withdraw(double, string);
  void transfer(double, string);
  void printBalances();
  
  int main()
  {
      string accountChoice;
      int selection;
      double transaction = 0;
  
      //  !!!!!!!!!!!!!!!!!!HAVE TO STILL COMPUTE INTEREST!!!!!!!!!!!!!!!!
  
      cout &lt;&lt; fixed &lt;&lt; showpoint &lt;&lt; setprecision(2);
  
      do
      {
          cout &lt;&lt; "Please make a selection:" &lt;&lt; endl;
          cout &lt;&lt; "1.) Deposit" &lt;&lt; endl;
          cout &lt;&lt; "2.) Withdraw" &lt;&lt; endl;
          cout &lt;&lt; "3.) Transfer" &lt;&lt; endl;
          cout &lt;&lt; "4.) Print balances" &lt;&lt; endl;
          cout &lt;&lt; "5.) Quit" &lt;&lt; endl;
          cin &gt;&gt; selection;
  
          if(selection == 1)
          {
              cout &lt;&lt; endl &lt;&lt; "Please select the account you would like to perform operations on(S or C):" &lt;&lt; endl;
              cin &gt;&gt; accountChoice;
              cout &lt;&lt; endl &lt;&lt; "Please enter the amount to be deposited:" &lt;&lt; endl;
              cin &gt;&gt; transaction;
              cout &lt;&lt; endl;
  
              deposit(transaction, accountChoice);
          }
          else if(selection == 2)
          {
              cout &lt;&lt; endl &lt;&lt; "Please select the account you would like to perform operations on(S or C):" &lt;&lt; endl;
              cin &gt;&gt; accountChoice;
              cout &lt;&lt; endl &lt;&lt; "Please enter the amount to be withdrawn:" &lt;&lt; endl;
              cin &gt;&gt; transaction;
              cout &lt;&lt; endl;
  
              withdraw(transaction, accountChoice);
          }
          else if(selection == 3)
          {
              cout &lt;&lt; endl &lt;&lt; "Please select the account you would like to perform operations on(S or C):" &lt;&lt; endl;
              cin &gt;&gt; accountChoice;
              cout &lt;&lt; endl &lt;&lt; "Please enter the amount to be transferred:" &lt;&lt; endl;
              cin &gt;&gt; transaction;
              cout &lt;&lt; endl;
  
              transfer(transaction, accountChoice);
          }
          else if(selection == 4)
              printBalances();
          else
              cout &lt;&lt; "Closing program -- Thank you for using the ATM teller!" &lt;&lt; endl;
      }while(selection != 5);
  
  
      system("pause");
      return 0;
  }
  
  void deposit(double amount, string account)
  {
      Account savings, checking;
  
      if(account == "S" || account == "s")
          savings.Add(amount);
      else
          checking.Add(amount);
  }
  
  void withdraw(double amount, string account)
  {
      Account savings, checking;
  
      if(account == "S" || account == "s")
          savings.Withdraw(amount);
      else
          checking.Withdraw(amount);
  }
  
  void transfer(double amount, string account)
  {
      Account savings, checking;
  
      if(account == "S" || account == "s")
      {
          savings.Withdraw(amount);
          checking.Add(amount);
      }
      else
      {
          checking.Withdraw(amount);
          savings.Add(amount);
      }
  }
  
  void printBalances()
  {
      Account savings, checking;
  
      cout &lt;&lt; "The current balance in savings is: " &lt;&lt; savings.GetBalance() &lt;&lt; endl;
      cout &lt;&lt; "The current balance in checking is: " &lt;&lt; checking.GetBalance() &lt;&lt; endl &lt;&lt; endl;
  }
  </code></pre>