title: Calculating tax owed with thresholds and rates in java
body: <p>for a part of my revenue program I am making as an assignment for school I have to calculate a number which is the Total Tax Owed from a citizen. I am given in a text file the number of thresholds, the threshold value, and the rate at each threshold. An example is </p>
  
  <pre><code>Threshold   Rate
  $15,000 15%
  $29,000 20%
  $50,000 25%
  </code></pre>
  
  <p>A citizen whose net income is $55,000 would pay:
  $15,000*0%+$14,000*15%+$21,000*20%+$5,000*25% = $7,550</p>
  
  <p>I have started my method here</p>
  
  <pre><code>private void computeTaxOwed(Citizen cit, TaxSchedule sked){
  
      double netIncome = cit.getNetIncome();
      double totTaxPaid = cit.getTotTaxPaid();
  
      int levels = sked.getNumLevels();
      double[] threshold = sked.getThreshold();
      double[] rate = sked.getRate();
  
      double taxOwd = 0;
  
      for(int i = levels; i&gt;0; i--){
          taxOwd = ((netIncome-threshold[i])*rate[i]);
      }
  </code></pre>
  
  <p>I know this will not give the correct output and I just can't figure out how to make this algorithm work. If I could extract the values of both arrays and save them each to an individual variable I could easily get the right output but I think that is very messy and not the best way to do it.</p>
  
  <p>Any ideas would be greatly appreciated!</p>