title: C++ basic menu driven program (calling functions)
body: <p>I'm new to programming and am trying to figure out why this is happening.  </p>
  
  <p>Basically I'm asked to design a menu driven program that does some basic deposit/withdrawal calculations.  I'm supposed to write different functions for each process and call on them when necessary.</p>
  
  <p>I'm having 2 problems:
  1) My functions aren't updating my variables within the program.  For example it will run, I can enter my starting balance, I can enter my transaction type and amount but every time I switch from deposit to writing a check, it resets the balance to the original user input.</p>
  
  <p>2) When I want the program to exit, it is still asking me for the double input.  Not sure how to make it accept just an "E" instead of "E number"</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;string&gt;
  using namespace std;
  
  //Prototypes for my functions that will be called in
  void displayMenu();
  double checkProcess(double, double);
  double depositProcess(double, double);
  double totalServCharge(double);
  
  int main()
  {
          //Variables needed for the problem
          char choice; //menu choice
      double transAmt, balance, numbServCharge; //transaction amount, current balance, total service charges, number of service charges
  
      numbServCharge = 0; //Start the counter for number of service charges at zero
      cout &lt;&lt; "Checkbook Program\n\n";
      cout &lt;&lt; "Enter the beginning balance:  "; 
      cin &gt;&gt; balance; //get the initial balance
      cout &lt;&lt; endl;
  
      do
      {
          //Call the display menu function
          displayMenu();
  
          //Get user's choice and transaction amount from menu
          cout &lt;&lt; "Enter a transaction:  ";
          cin &gt;&gt; choice &gt;&gt; transAmt;
          choice = toupper(choice);
          cout &lt;&lt; endl;
  
          //Create an error message for invalid choice and get a second choice
          while((choice != 'C') &amp;&amp; (choice != 'D') &amp;&amp; (choice != 'E'))
          {
          cout &lt;&lt; "Invalid selection.  Please choose C, D or E: ";
          cin &gt;&gt; choice;
          }
  
          //Set up for option #1 -- using a check
          if(choice=='C')
          {
          //Call check function and service charges function
          checkProcess(transAmt, balance);
          totalServCharge(numbServCharge);
          }
  
          //Set up for option #2 -- deposits
          if(choice=='D')
          {
          //Call deposit function and service charges function
          depositProcess(transAmt, balance);
          totalServCharge(numbServCharge);
          }
  
      }while(choice != 'E'); //Close program if option 3 is selected
  
      //Display final balance
      cout &lt;&lt; "Processing end of the month";
      cout &lt;&lt; "\nFinal balance :  $  " &lt;&lt; fixed &lt;&lt; setprecision(2) &lt;&lt; balance &lt;&lt; endl &lt;&lt; endl;
  
      system("pause"); //Pause screen so it doesn't close right away
      return 0;
  }
  
  void displayMenu()
  {
  //Highlight menu options
  cout &lt;&lt; "\nCommands\n";
  cout &lt;&lt; "C amount - process a check in a specific amount\n";
  cout &lt;&lt; "D amount - process a deposit in a specific amount\n";
  cout &lt;&lt; "E - end the program\n\n";
  }
  
  double checkProcess(double transAmt, double balance)
  {
  cout &lt;&lt; "\nProcessing check for $" &lt;&lt; fixed &lt;&lt; setprecision(2) &lt;&lt; transAmt;
  transAmt = transAmt + .25; //Add the service charge onto the transaction
  balance = balance - transAmt; //Update account balence
  cout &lt;&lt; "\nBalance:  $" &lt;&lt; fixed &lt;&lt; setprecision(2) &lt;&lt; balance;
  cout &lt;&lt; "\nService charge:  $0.25 for a check\n";
  return balance;
  }
  
  double depositProcess(double transAmt, double balance)
  {
  cout &lt;&lt; "\nProcessing Deposit for $" &lt;&lt; fixed &lt;&lt; setprecision(2) &lt;&lt; transAmt &lt;&lt; endl;
  transAmt = transAmt - 0.25; //Add the service charge onto the deposit
  balance = balance + transAmt; //Update account balence
  cout &lt;&lt; "Balance:  $" &lt;&lt; fixed &lt;&lt; setprecision(2) &lt;&lt; balance &lt;&lt; endl;
  return balance;
  }
  
  double totalServCharge(double numbServCharge)
  {
  double totalServCharge = 0;
  numbServCharge++; //Add one to the number of service charges there have been
  totalServCharge = .25 * numbServCharge; //Update total cost of service charges
  cout &lt;&lt; "Total service charges:  $" &lt;&lt; fixed &lt;&lt; setprecision(2) &lt;&lt; totalServCharge &lt;&lt; endl; //Tell user total service charges so far
  return numbServCharge;
  }
  </code></pre>