title: Displaying receipt from user input
body: <p>I'am new in c++ programming.So I take another people program and I try to using array for the program fix but I don't know the syntax and I still don't understand what kind of array that will do to fix this program because I cant put like food[i+1] to print all the item in the receipt
  <a href="https://www.dreamincode.net/forums/topic/385630-displaying-users-inputs-in-receipt/" rel="nofollow noreferrer">https://www.dreamincode.net/forums/topic/385630-displaying-users-inputs-in-receipt/</a></p>
  <pre><code>    #include&lt;iostream&gt;
      #include&lt;iomanip&gt;
      #include&lt;string&gt;
      using namespace std;
      
      void mainMenu();
      
      
      void totalCost();
      double total;     
      
      int main()
      {
          string choice;
          
          char menuOption;    
      
          mainMenu();
      do
      {
          cin &gt;&gt; menuOption;
          switch (menuOption)
          {
          case '1':
              choice = &quot;Sandwich&quot;;
              total +=4.99;
              mainMenu();
              break;
          case '2':
              choice = &quot;Soup of the Day&quot;;
              total += 2.99;
              cout &lt;&lt; endl;
              mainMenu();
              break;
          case '3':
                          choice = &quot;Mac and Cheese&quot;;
  
              total += 3.99;
              cout &lt;&lt; endl;
              mainMenu();
          case '4':
                          choice = &quot;Bagel with Cream Cheese&quot;;
              total += 1.99;
              cout &lt;&lt; endl;
              mainMenu();
              break;
          
          case '5':
              cout &lt;&lt; &quot;Thank you for ordering!&quot;;
              cout &lt;&lt; endl;
              totalCost();
              break;
          default:
              cout &lt;&lt; &quot;Please enter the number from the menu&quot;;
              cout &lt;&lt; &quot; you wish to add to your order, then press enter&quot;;
              cout &lt;&lt; endl;
              mainMenu();
              break;
          }
      } while (menuOption != '5');
  
      cout &lt;&lt; &quot;\nHere is your receipt!&quot; &lt;&lt; endl;
      cout &lt;&lt; choice &lt;&lt; endl; //This should display all the choices the user selected
      cout &lt;&lt; &quot;Your total will be &quot; &lt;&lt; total &lt;&lt; endl;
      system(&quot;PAUSE&quot;);
      return 0;
  }
  
  void mainMenu()
  {
      cout &lt;&lt; &quot;Please select from option below&quot;;
      
      cout &lt;&lt; &quot;[1] - Sandwiches $4.99\n&quot;;
      cout &lt;&lt; &quot;[2] - Soups of the Day $2.99\n&quot;;
      cout &lt;&lt; &quot;[3] - Mac and Cheese $3.99\n&quot;;
      cout &lt;&lt; &quot;[4] - Bagel with Cream Cheese $1.99\n&quot;;
      cout &lt;&lt; &quot;[5] - Total your entire order when you're finished\n&quot;;
  }
  
  void totalCost()
  {
      total = total;
  }
  </code></pre>