title: Tax Calculator C++
body: <p>I am writing a program to calculate taxes based on marital status, number of children under the age of 14, gross salary, and percentage of gross salary contributed to a pension fund. Everything seems correct, but the marital status, number of children, gross salary, and pension fund percentage are not able to be seen in my function taxAmount. I thought that using an ampersand (&amp;) would make the values viewable by my other function. I cannot change the number of functions that I have, I must stick with the two I am currently working with. Does anyone have suggestions as to how I can fix my problem? The error message says that marital, children, grossSalary, and pension are not declared in the scope.</p>
  
  <p>The prototypes are:</p>
  
  <pre><code>void getData(char&amp;, int&amp;, int&amp;, int&amp;);
  int taxAmount(int);
  </code></pre>
  
  <p>My main function:</p>
  
  <pre><code>int main()
  {
      char marital;
      int children;
      int grossSalary;
      int pension;
  
      int amount;
  
      getData(marital, children, grossSalary, pension);
  
      cout &lt;&lt; "The tax amount is: $" &lt;&lt; taxAmount(amount) &lt;&lt; endl;
  
  
      _getch();
      return 0;
  }
  </code></pre>
  
  <p>My function to get data:</p>
  
  <pre><code>void getData(char&amp; marital, int&amp; children, int&amp; grossSalary, int&amp; pension)
  {
      cout &lt;&lt; "Enter your marital status. Enter 'm' for married. Enter 's' for";
      cout &lt;&lt; " single. \n";
      cin &gt;&gt; marital;
      cout &lt;&lt; endl;
  
      cout &lt;&lt; "Enter the number of children you have under the age of 14. \n";
      cin &gt;&gt; children;
      cout &lt;&lt; endl;
  
      cout &lt;&lt; "Enter your gross salary. If you are married, enter the combined";
      cout &lt;&lt; " income of you and your spouse.";
      cin &gt;&gt; grossSalary;
      cout &lt;&lt; endl;
  
      cout &lt;&lt; "Enter the number of the percentage (up to 6) of your gross";
      cout &lt;&lt; " income contributed to a pension fund.";
      cin &gt;&gt; pension;
      cout &lt;&lt; endl;
  }
  </code></pre>
  
  <p>My function to calculate the amount (code removed):</p>
  
  <pre><code>int taxAmount(int amount)
  {
  ...
  }
  </code></pre>