title: Restaurant Billing Program Function
body: <p>I need to make a restaurant bill calculator program that allows people to choose from a list of menu items (a function) until they have everything they've wanted to order and then calculate the total when they are finished selecting from a list. Then it takes the amount they tender and subtracts the total plus tax and tip to calculate change.</p>
  
  <p>I've found several ideas and similar programs here and on other places but nothing that has given me a good enough idea of how to get this finalized. I have the program coded but I can't figure out how to take the running total and keep accumulating it until the user enters "8". I have a functioning program but it totals after each selection instead of keeping a running total and calcuating it when the user hits the "8" key to end.</p>
  
  <p>Take a look below and see if you can point my in the right direction if you would. Basically this assignment is about functions so we're asked to use functions to display the menu and calculate the total.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  using namespace std;
  
  // Function Prototypes
  void showMenu();
  void showFees(double, int);
  
  int main()
  {
      int choice; //To Hold Menu Choice
      double quantity = 1;
  
  
  
  
      //contants for menu choices
      const int hamburgerChoice = 1;
      const int hotdogChoice = 2;
      const int peanutsChoice = 3;
      const int popcornChoice = 4;
      const int sodaChoice = 5;
      const int chipsChoice = 6;
      const int waterChoice = 7;
      const int endOrderChoice = 8;
  
      //constants for menu prices
      const double hamburger = 6.00;
      const double hotdog = 4.50;
      const double peanuts = 3.75;
      const double popcorn = 5.50;
      const double soda = 2.80;
      const double chips = 1.00;
      const double water = 2.00;
  
      //set precision
      cout &lt;&lt; fixed &lt;&lt; showpoint &lt;&lt; setprecision(2);
  
      do
      {
          //display menu and get user choice
          showMenu();
          cin &gt;&gt; choice;
  
          //validate choice
          while (choice &lt; hamburgerChoice || choice &gt; endOrderChoice)
          {
              cout &lt;&lt; "Please enter a valid menu choice: ";
              cin &gt;&gt; choice;
          }
  
          //if the user does not want to quit proceed
          if (choice != endOrderChoice)
          {
  
              //display fees
              switch (choice)
              {
                  case hamburgerChoice:
                      showFees(hamburger, quantity);
                      break;
                  case hotdogChoice:
                      showFees(hotdog, quantity);
                      break;
                  case peanutsChoice:
                      showFees(peanuts, quantity);
                      break;
                  case popcornChoice:
                      showFees(popcorn, quantity);
                      break;
                  case sodaChoice:
                      showFees(soda, quantity);
                      break;
                  case chipsChoice:
                      showFees(chips, quantity);
                      break;
                  case waterChoice:
                      showFees(water, quantity);
                      break;
  
              }
                      }
      }
      while (choice != endOrderChoice);
      system("pause");
      return 0;
  
  }
  //*************************************************************
  //Definition of function showMenu which displays the menu    **
  //*************************************************************
  
  void showMenu()
  {
      cout &lt;&lt; "\n\t\tBaseball Game Snacks" &lt;&lt; endl;
      cout &lt;&lt; "1. Hamburger \t$6.00"&lt;&lt; endl;
      cout &lt;&lt; "2. Hotdog \t\t$4.50" &lt;&lt; endl;
      cout &lt;&lt; "3. Peanuts \t\t$3.75" &lt;&lt; endl;
      cout &lt;&lt; "4. Popcorn \t\t$5.50" &lt;&lt; endl;
      cout &lt;&lt; "5. Soda \t\t$2.80" &lt;&lt; endl;
      cout &lt;&lt; "6. Chips \t\t$1.00"&lt;&lt; endl;
      cout &lt;&lt; "7. Water \t\t$2.00" &lt;&lt; endl;
      cout &lt;&lt; "8. END ORDER" &lt;&lt; endl;
      cout &lt;&lt; "Please enter your menu choice: ";
  }
  
  //************************************************************
  //Definition of function showFees which caculates the total **
  //bill                                                      **
  //************************************************************
  
  void showFees(double itemCost, int quantity)
  {
      double amtTendered;
      double totalBill = (itemCost * quantity);
      double taxRate = .065;
      double tipRate = .20;
      double tip = (totalBill * tipRate);
      double tax = (totalBill * taxRate);
      double amountDue = (totalBill + tax + tip);
      cout &lt;&lt; "Total Bill: $" &lt;&lt; totalBill &lt;&lt; endl;
      cout &lt;&lt; "Tax: $" &lt;&lt; tax &lt;&lt; endl;
      cout &lt;&lt; "Tip: $" &lt;&lt; tip &lt;&lt; endl;
      cout &lt;&lt; "Total Amount Due: $" &lt;&lt; amountDue &lt;&lt; endl;
      cout &lt;&lt; "Enter ammount tendered: $";
      cin &gt;&gt; amtTendered;
      double changeDue = amtTendered - amountDue;
      cout &lt;&lt; "Change Due: $" &lt;&lt; changeDue &lt;&lt; endl;
  
  }
  </code></pre>