package com.blocksolid.income;

/**
 * Created by Dan Buckland on 16/09/2015.
 */

public class TaxCalculator {

    int MAX_PERSONAL_ALLOWANCE = 1060000;           // £10,600
    int PERSONAL_ALLOWANCE_THRESHOLD = 10000000;    // £100,000
    int BASIC_RATE_THRESHOLD = 3178500;             // £31,785
    int HIGHER_RATE_THRESHOLD = 15000000;           // £150,000

    int annualIncome = 0;
    int personalAllowance = MAX_PERSONAL_ALLOWANCE;

    public TaxCalculator() {

    }

    public void setAnnualIncome(int newAnnualIncome) {
        annualIncome = newAnnualIncome;
    }

    public int getAnnualIncome() {
        return annualIncome;
    }

    public int calculatePersonalAllowance(int annualIncome) {
        if (annualIncome > PERSONAL_ALLOWANCE_THRESHOLD) {
            int difference = annualIncome - PERSONAL_ALLOWANCE_THRESHOLD;
            if (difference % 200 > 0) {
                difference = difference - 100;
            }
            personalAllowance = MAX_PERSONAL_ALLOWANCE - (difference / 2);
            if (personalAllowance < 0) {
                personalAllowance = 0;
            }
        } else {
            personalAllowance = MAX_PERSONAL_ALLOWANCE;
        }
        return personalAllowance;
    }

}
@@ -716,140 +716,810 @@
 ) %7B%0A
-        if (annualIncome %3E PERSONAL_ALLOWANCE_THRESHOLD) %7B%0A            int difference = annualIncome - PERSONAL_ALLOWANCE_THRESHOLD;
+%0A        /**%0A         * The standard Personal Allowance is %C2%A310,600, which is the amount of income that tax will%0A         * not be paid on.%0A         *%0A         * A persons Personal Allowance may be bigger if they were born before 6 April 1938 or if%0A         * they get Blind Person%E2%80%99s Allowance.%0A         *%0A         * The Personal Allowance goes down by %C2%A31 for every %C2%A32 that the adjusted net income is%0A         * above %C2%A3100,000. This means the allowance is zero if a persons income is %C2%A3121,200 or over.%0A         */%0A%0A        if (annualIncome %3E PERSONAL_ALLOWANCE_THRESHOLD) %7B%0A            int difference = annualIncome - PERSONAL_ALLOWANCE_THRESHOLD;%0A            // %C2%A31 is removed for each %C2%A32 earned above the personal allowance%0A            // Remove the odd pound so that the difference can be divided by 2
 %0A   
@@ -1691,16 +1691,108 @@
 e / 2);%0A
+            // If the calculation results in a negative number, set personal allowance to 0%0A
         
@@ -1894,16 +1894,102 @@
  else %7B%0A
+            // Personal allowance set to the maximum if salary is below the threshold%0A
         

Add comments to method for future sanity