title: Java while loop conversion.
body: <p>I have this method that computes taxes due for a person with a filing status of single.
  But I'm having trouble trying to convert this to a for loop or using an Array instead of a while loop because this code becomes really long and nasty looking. I want to make it look pretty by simplifying the code. Any suggestions?</p>
  
  <pre><code>public void calculateTax()
      {
          //The constant fields for the tax rate
          final double TAXRATE_10 = 0.1;     //10%
          //This is the tax rate percent on the tax 15%
          final double TAXRATE_15PERCENT = 0.15;
          //This is the tax rate percent on the tax 25%
          final double TAXRATE_25PERCENT = 0.25;
          //This is the tax rate percent on the tax 28%
          final double TAXRATE_28PERCENT = 0.28;
          //This is the tax rate percent on the tax 33%
          final double TAXTRATE_33PERCENT = 0.33;
          //This is the tax rate percent on the tax 35%
          final double TAXRATE_35PERCENT = 0.35;
  
          //constant numbers for tax boundaries.
          final int NOTRICH = 8700;
          final int MIDDLECLASS = 35350;
          final int SORTOFRICH = 85650;
          final int RICH = 178650;
          final int FORSURERICH = 388350;
  
          //Variables for taxable income, and tax calculation.
          long taxableIncome = income - deduction -(numberOfExemption * VAlUEOFEXEMPTION);
          double cumulatedTax = 0;
  
          //Calculate the Tax
          while(taxableIncome != 0)
          {
              if(taxableIncome &gt; FORSURERICH)
              {
                  cumulatedTax += ((taxableIncome-FORSURERICH) * TAXRATE_35PERCENT);
                  taxableIncome = (long)FORSURERICH;
              }
              else if(taxableIncome &gt; RICH)
              {
                  cumulatedTax += ((taxableIncome-RICH) * TAXTRATE_33PERCENT);
                  taxableIncome = (long)RICH;
              }
              else if(taxableIncome &gt; SORTOFRICH)
              {
                  cumulatedTax += ((taxableIncome-SORTOFRICH) * TAXRATE_28PERCENT);
                  taxableIncome = (long)SORTOFRICH;
              }
              else if(taxableIncome &gt; MIDDLECLASS)
              {
                  cumulatedTax += ((taxableIncome-MIDDLECLASS) * TAXRATE_25PERCENT);
                  taxableIncome = (long)MIDDLECLASS;
              }
              else if(taxableIncome &gt; NOTRICH)
              {
                  cumulatedTax += ((taxableIncome-NOTRICH) * TAXRATE_15PERCENT);
                  taxableIncome = (long)NOTRICH;
              }
              else
              {
                  cumulatedTax += ((taxableIncome) * TAXRATE_10);
                  taxableIncome = 0;
              }
          }
  </code></pre>