public double calculate(TaxCalculationConditions conditions) { double tax; if (conditions.Income < 2000) { tax = conditions.Income * 0.05; } else if (conditions.Income < 5000) { tax = conditions.Income * 0.1; } else if (conditions.Income < 10000) { tax = conditions.Income * 0.15; } else { tax = conditions.Income * 0.20; } if (conditions.Nationality == Nationality.US) { tax += conditions.Income * 0.05; } return(Math.Round(tax, 2)); }
public double calculate(TaxCalculationConditions conditions) { double tax; int years = DateTime.Now.Year - conditions.BirthDate.Year; if (years < 20) { return(0); } if (conditions.Income < 2000) { tax = conditions.Income * 0.05; } else if (conditions.Income < 5000) { tax = conditions.Income * 0.1; } else if (conditions.Income < 10000) { tax = conditions.Income * 0.15; } else { tax = conditions.Income * 0.20; } tax += conditions.Income * 0.05; return(Math.Round(tax, 2)); }
public double calculate(TaxCalculationConditions conditions) { double tax; //US if (conditions.Nationality == Nationality.US) { int years = DateTime.Now.Year - conditions.BirthDate.Year; if (years < 20) { tax = 0; } else { if (conditions.Income < 2000) { tax = conditions.Income * 0.05; } else if (conditions.Income < 5000) { tax = conditions.Income * 0.1; } else if (conditions.Income < 10000) { tax = conditions.Income * 0.15; } else { tax = conditions.Income * 0.20; } tax += conditions.Income * 0.05; } } //Canada else if (conditions.Nationality == Nationality.Canada) { if (conditions.Income < 1500) { tax = conditions.Income * 0.05; } else if (conditions.Income < 3000) { tax = conditions.Income * 0.1; } else if (conditions.Income < 7000) { tax = conditions.Income * 0.15; } else { tax = conditions.Income * 0.20; } } //EGYPT else { tax = conditions.Income * 0.05; } return(Math.Round(tax, 2)); }
public double calculate(TaxCalculationConditions conditions) { ITaxCalculator taxCalculator = null; //Strategy Pattern if (conditions.Nationality == Nationality.US) { taxCalculator = new USTaxCalculator(); } else { taxCalculator = new CanadaTaxCalculator(); } return(taxCalculator.calculate(conditions)); }
public double calculate(TaxCalculationConditions conditions) { double tax; if (conditions.Income < 1500) { tax = conditions.Income * 0.05; } else if (conditions.Income < 3000) { tax = conditions.Income * 0.1; } else if (conditions.Income < 7000) { tax = conditions.Income * 0.15; } else { tax = conditions.Income * 0.20; } return(Math.Round(tax, 2)); }
public double calculate(TaxCalculationConditions conditions) { return(conditions.Income * 0.05); }
public double calculate(TaxCalculationConditions conditions) { ITaxCalculator taxCalculator = TaxCalculatorFactory.createCalculator(conditions.Nationality); return(taxCalculator.calculate(conditions)); }