Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F86356
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
21 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2caa445
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+taxcalculator2/.idea
+taxcalculator2/target
diff --git a/nz/ac/massey/cs/sdc/taxcalculator/IncomeTaxCalculator.java b/nz/ac/massey/cs/sdc/taxcalculator/IncomeTaxCalculator.java
new file mode 100755
index 0000000..5561522
--- /dev/null
+++ b/nz/ac/massey/cs/sdc/taxcalculator/IncomeTaxCalculator.java
@@ -0,0 +1,29 @@
+package nz.ac.massey.cs.sdc.taxcalculator;
+/**
+ * A simple tax calculator implementing the NZ tax rules accourding to
+ * http://www.ird.govt.nz/how-to/taxrates-codes/itaxsalaryandwage-incometaxrates.html
+ * accessed on 9 August 12
+ * @author jens dietrich
+ */
+public class IncomeTaxCalculator {
+
+ double[] brackets = {0,14000,48000,70000};
+ double[] taxRates = {10.5,17.5,30,33};
+ public double calculateIncomeTax(double income) {
+ // disable the next line to introduce an artificial delay - this will cause test cases with timeouts to fail
+ // try {Thread.sleep(200);} catch (Exception x){}
+ if (income<0) throw new IllegalArgumentException("the income must be positive");
+ double tax = 0.0;
+ for (int i=brackets.length-1;i>=0;i--) {
+ double bracket = brackets[i];
+ double taxRate = taxRates[i];
+ if (income>bracket) {
+ double taxableInThisBracket = income-bracket;
+ income = income - taxableInThisBracket;
+ tax = tax + taxableInThisBracket*taxRate/100;
+ }
+ }
+ return tax;
+ }
+
+}
diff --git a/nz/ac/massey/cs/sdc/taxcalculator/ui/TaxCalculatorUI.java b/nz/ac/massey/cs/sdc/taxcalculator/ui/TaxCalculatorUI.java
new file mode 100755
index 0000000..315fe54
--- /dev/null
+++ b/nz/ac/massey/cs/sdc/taxcalculator/ui/TaxCalculatorUI.java
@@ -0,0 +1,145 @@
+
+package nz.ac.massey.cs.sdc.taxcalculator.ui;
+
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.text.NumberFormat;
+import java.util.Locale;
+import javax.swing.*;
+import nz.ac.massey.cs.sdc.taxcalculator.IncomeTaxCalculator;
+
+/**
+ * Swing based-user interface for the tax calculator.
+ * This class is executable, i.e. it has a main method.
+ * @author Jens Dietrich
+ * @version 1.2
+ * @since 1.1
+ */
+
+public class TaxCalculatorUI extends JFrame {
+
+ private static final long serialVersionUID = -249195317281900474L;
+ // model
+ private IncomeTaxCalculator taxCalculator = new IncomeTaxCalculator();
+ // components
+ NumberFormat numberFormat = NumberFormat.getInstance(Locale.UK);
+ JFormattedTextField incomeField = new JFormattedTextField(numberFormat);
+ JFormattedTextField taxField = new JFormattedTextField(numberFormat);
+ JLabel incomeLabel = new JLabel("Income:");
+ JLabel taxLabel = new JLabel("Income Tax:");
+ JButton computeButton = new JButton("Compute Income Tax");
+ JButton exitButton = new JButton("Exit Application");
+
+ /**
+ * Main method - launch the UI.
+ */
+ public static void main(String[] args) {
+ TaxCalculatorUI application = new TaxCalculatorUI();
+ application.setSize(500,125);
+ application.setLocation(400,300);
+ application.setResizable(false);
+ application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ application.setVisible(true);
+ }
+
+
+ public IncomeTaxCalculator getTaxCalculator() {
+ return taxCalculator;
+ }
+ public void setTaxCalculator(IncomeTaxCalculator taxCalculator) {
+ this.taxCalculator = taxCalculator;
+ }
+
+ /**
+ * Constructor.
+ */
+ public TaxCalculatorUI() {
+ super("Tax Calculator");
+ init();
+ }
+ /**
+ * Initialize the user interface.
+ */
+ private void init() {
+ JPanel contentPane = new JPanel(new BorderLayout(5,5));
+ this.setContentPane(contentPane);
+
+ taxField.setEditable(false);
+
+ JPanel main = new JPanel();
+ main.setLayout(new GridLayout(2,3,5,5));
+ main.add(incomeLabel);
+ main.add(taxLabel);
+ main.add(incomeField);
+ main.add(taxField);
+ main.setBorder(BorderFactory.createEmptyBorder(5,25,5,25));
+ contentPane.add(main,BorderLayout.CENTER);
+
+ JPanel toolbar = new JPanel(new FlowLayout(FlowLayout.CENTER));
+ toolbar.add(computeButton);
+ computeButton.setMnemonic('c');
+ toolbar.add(exitButton);
+ exitButton.setMnemonic('x');
+ contentPane.add(toolbar,BorderLayout.SOUTH);
+
+ computeButton.addActionListener(
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ computeIncomeTax();
+ }
+ }
+ );
+ exitButton.addActionListener(
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ dispose();
+ }
+ }
+ );
+ this.incomeField.addKeyListener(
+ new KeyListener() {
+
+ public void keyPressed(KeyEvent e) {
+ taxField.setText("");
+ }
+ public void keyReleased(KeyEvent e) {
+ taxField.setText("");
+ }
+ public void keyTyped(KeyEvent e) {
+ taxField.setText("");
+ }
+ }
+ );
+ }
+ /**
+ * Compute the income tax.
+ */
+ private void computeIncomeTax() {
+ try {
+ String incomeAsText = this.incomeField.getText();
+ double income = Double.valueOf(""+numberFormat.parse(incomeAsText));
+ double tax = this.taxCalculator.calculateIncomeTax(income);
+ this.taxField.setValue(tax);
+ }
+ catch (Exception x) {
+ handleException(x);
+ }
+ }
+ /**
+ * Handle exceptions.
+ * @param x an exception
+ */
+ private void handleException(Throwable x) {
+ x.printStackTrace();
+ JOptionPane.showMessageDialog(this,"<html>An error has occured.<br>Details have been logged</html>","Error",JOptionPane.ERROR_MESSAGE);
+ this.taxField.setText("");
+ }
+
+
+ }
+
+
+
diff --git a/taxcalculator2/pom.xml b/taxcalculator2/pom.xml
new file mode 100644
index 0000000..1f86606
--- /dev/null
+++ b/taxcalculator2/pom.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>nz.ac.massey.sdc</groupId>
+ <artifactId>taxcalculator</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <version>20160810</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.17</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/taxcalculator2/src/main/java/nz/ac/massey/cs/sdc/taxcalculator/IncomeTaxCalculator.java b/taxcalculator2/src/main/java/nz/ac/massey/cs/sdc/taxcalculator/IncomeTaxCalculator.java
new file mode 100755
index 0000000..097178e
--- /dev/null
+++ b/taxcalculator2/src/main/java/nz/ac/massey/cs/sdc/taxcalculator/IncomeTaxCalculator.java
@@ -0,0 +1,25 @@
+package nz.ac.massey.cs.sdc.taxcalculator;
+/**
+ * A simple tax calculator implementing the NZ tax rules accourding to
+ * http://www.ird.govt.nz/how-to/taxrates-codes/itaxsalaryandwage-incometaxrates.html
+ * accessed on 9 August 12
+ * @author jens dietrich
+ */
+public class IncomeTaxCalculator {
+
+ public double calculateIncomeTax(double income) {
+ // disable the next line to introduce an artificial delay - this will cause test cases with timeouts to fail
+ // try {Thread.sleep(200);} catch (Exception x){}
+ if (income<0) throw new IllegalArgumentException("the income must be positive");
+ TaxBracket[] brackets = MasterDataReader.getTaxBrackets();
+ double tax = 0.0;
+ for (TaxBracket bracket:brackets) {
+ if (income>bracket.getStart()) {
+ double taxableInThisBracket = income>bracket.getEnd()?bracket.getEnd()- bracket.getStart():income-bracket.getStart();
+ tax = tax + taxableInThisBracket*bracket.getTaxRate()/100;
+ }
+ }
+ return tax;
+ }
+
+}
diff --git a/taxcalculator2/src/main/java/nz/ac/massey/cs/sdc/taxcalculator/MasterDataReader.java b/taxcalculator2/src/main/java/nz/ac/massey/cs/sdc/taxcalculator/MasterDataReader.java
new file mode 100644
index 0000000..d691843
--- /dev/null
+++ b/taxcalculator2/src/main/java/nz/ac/massey/cs/sdc/taxcalculator/MasterDataReader.java
@@ -0,0 +1,45 @@
+package nz.ac.massey.cs.sdc.taxcalculator;
+
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.Logger;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Utility to read tax brackets.
+ * @author jens dietrich
+ */
+public class MasterDataReader {
+ public static TaxBracket[] getTaxBrackets() {
+ BasicConfigurator.configure();
+ Logger logger = Logger.getLogger(MasterDataReader.class);
+
+ String taxbracketDefs = "taxbrackets.json";
+ try {
+ List<TaxBracket> brackets = new ArrayList<TaxBracket>();
+ logger.info("importing tax brackets from " + new File(taxbracketDefs).getAbsolutePath());
+ FileInputStream in = new FileInputStream(taxbracketDefs);
+ JSONTokener tokener = new JSONTokener(in);
+ JSONArray jsonArray = new JSONArray(tokener);
+ for (int i=0;i<jsonArray.length();i++) {
+ JSONObject jsonObj = jsonArray.getJSONObject(i);
+ TaxBracket bracket = new TaxBracket(
+ jsonObj.getDouble("start"),
+ jsonObj.getDouble("end")==-1?Double.MAX_VALUE:jsonObj.getDouble("end"),
+ jsonObj.getDouble("rate")
+ );
+ brackets.add(bracket);
+ }
+ return brackets.toArray(new TaxBracket[jsonArray.length()]);
+ }
+ catch (Exception x) {
+ logger.error("exception importing tax brackets from " + new File(taxbracketDefs).getAbsolutePath(),x);
+ throw new IllegalStateException("Cannot initialise data needed");
+ }
+ }
+}
diff --git a/taxcalculator2/src/main/java/nz/ac/massey/cs/sdc/taxcalculator/TaxBracket.java b/taxcalculator2/src/main/java/nz/ac/massey/cs/sdc/taxcalculator/TaxBracket.java
new file mode 100644
index 0000000..54f0878
--- /dev/null
+++ b/taxcalculator2/src/main/java/nz/ac/massey/cs/sdc/taxcalculator/TaxBracket.java
@@ -0,0 +1,69 @@
+package nz.ac.massey.cs.sdc.taxcalculator;
+
+/**
+ * Class representing a tax bracket.
+ * @author jens dietrich
+ */
+
+
+public class TaxBracket {
+ private double start = 0;
+ private double end = 0;
+ private double taxRate = 0;
+
+ public TaxBracket(double start, double end, double taxRate) {
+ this.start = start;
+ this.end = end;
+ this.taxRate = taxRate;
+ }
+
+ public double getStart() {
+ return start;
+ }
+
+ public void setStart(double start) {
+ this.start = start;
+ }
+
+ public double getEnd() {
+ return end;
+ }
+
+ public void setEnd(double end) {
+ this.end = end;
+ }
+
+ public double getTaxRate() {
+ return taxRate;
+ }
+
+ public void setTaxRate(double taxRate) {
+ this.taxRate = taxRate;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ TaxBracket that = (TaxBracket) o;
+
+ if (Double.compare(that.start, start) != 0) return false;
+ if (Double.compare(that.end, end) != 0) return false;
+ return Double.compare(that.taxRate, taxRate) == 0;
+
+ }
+
+ @Override
+ public int hashCode() {
+ int result;
+ long temp;
+ temp = Double.doubleToLongBits(start);
+ result = (int) (temp ^ (temp >>> 32));
+ temp = Double.doubleToLongBits(end);
+ result = 31 * result + (int) (temp ^ (temp >>> 32));
+ temp = Double.doubleToLongBits(taxRate);
+ result = 31 * result + (int) (temp ^ (temp >>> 32));
+ return result;
+ }
+}
diff --git a/taxcalculator2/src/main/java/nz/ac/massey/cs/sdc/taxcalculator/ui/TaxCalculatorUI.java b/taxcalculator2/src/main/java/nz/ac/massey/cs/sdc/taxcalculator/ui/TaxCalculatorUI.java
new file mode 100755
index 0000000..315fe54
--- /dev/null
+++ b/taxcalculator2/src/main/java/nz/ac/massey/cs/sdc/taxcalculator/ui/TaxCalculatorUI.java
@@ -0,0 +1,145 @@
+
+package nz.ac.massey.cs.sdc.taxcalculator.ui;
+
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.text.NumberFormat;
+import java.util.Locale;
+import javax.swing.*;
+import nz.ac.massey.cs.sdc.taxcalculator.IncomeTaxCalculator;
+
+/**
+ * Swing based-user interface for the tax calculator.
+ * This class is executable, i.e. it has a main method.
+ * @author Jens Dietrich
+ * @version 1.2
+ * @since 1.1
+ */
+
+public class TaxCalculatorUI extends JFrame {
+
+ private static final long serialVersionUID = -249195317281900474L;
+ // model
+ private IncomeTaxCalculator taxCalculator = new IncomeTaxCalculator();
+ // components
+ NumberFormat numberFormat = NumberFormat.getInstance(Locale.UK);
+ JFormattedTextField incomeField = new JFormattedTextField(numberFormat);
+ JFormattedTextField taxField = new JFormattedTextField(numberFormat);
+ JLabel incomeLabel = new JLabel("Income:");
+ JLabel taxLabel = new JLabel("Income Tax:");
+ JButton computeButton = new JButton("Compute Income Tax");
+ JButton exitButton = new JButton("Exit Application");
+
+ /**
+ * Main method - launch the UI.
+ */
+ public static void main(String[] args) {
+ TaxCalculatorUI application = new TaxCalculatorUI();
+ application.setSize(500,125);
+ application.setLocation(400,300);
+ application.setResizable(false);
+ application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ application.setVisible(true);
+ }
+
+
+ public IncomeTaxCalculator getTaxCalculator() {
+ return taxCalculator;
+ }
+ public void setTaxCalculator(IncomeTaxCalculator taxCalculator) {
+ this.taxCalculator = taxCalculator;
+ }
+
+ /**
+ * Constructor.
+ */
+ public TaxCalculatorUI() {
+ super("Tax Calculator");
+ init();
+ }
+ /**
+ * Initialize the user interface.
+ */
+ private void init() {
+ JPanel contentPane = new JPanel(new BorderLayout(5,5));
+ this.setContentPane(contentPane);
+
+ taxField.setEditable(false);
+
+ JPanel main = new JPanel();
+ main.setLayout(new GridLayout(2,3,5,5));
+ main.add(incomeLabel);
+ main.add(taxLabel);
+ main.add(incomeField);
+ main.add(taxField);
+ main.setBorder(BorderFactory.createEmptyBorder(5,25,5,25));
+ contentPane.add(main,BorderLayout.CENTER);
+
+ JPanel toolbar = new JPanel(new FlowLayout(FlowLayout.CENTER));
+ toolbar.add(computeButton);
+ computeButton.setMnemonic('c');
+ toolbar.add(exitButton);
+ exitButton.setMnemonic('x');
+ contentPane.add(toolbar,BorderLayout.SOUTH);
+
+ computeButton.addActionListener(
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ computeIncomeTax();
+ }
+ }
+ );
+ exitButton.addActionListener(
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ dispose();
+ }
+ }
+ );
+ this.incomeField.addKeyListener(
+ new KeyListener() {
+
+ public void keyPressed(KeyEvent e) {
+ taxField.setText("");
+ }
+ public void keyReleased(KeyEvent e) {
+ taxField.setText("");
+ }
+ public void keyTyped(KeyEvent e) {
+ taxField.setText("");
+ }
+ }
+ );
+ }
+ /**
+ * Compute the income tax.
+ */
+ private void computeIncomeTax() {
+ try {
+ String incomeAsText = this.incomeField.getText();
+ double income = Double.valueOf(""+numberFormat.parse(incomeAsText));
+ double tax = this.taxCalculator.calculateIncomeTax(income);
+ this.taxField.setValue(tax);
+ }
+ catch (Exception x) {
+ handleException(x);
+ }
+ }
+ /**
+ * Handle exceptions.
+ * @param x an exception
+ */
+ private void handleException(Throwable x) {
+ x.printStackTrace();
+ JOptionPane.showMessageDialog(this,"<html>An error has occured.<br>Details have been logged</html>","Error",JOptionPane.ERROR_MESSAGE);
+ this.taxField.setText("");
+ }
+
+
+ }
+
+
+
diff --git a/taxcalculator2/src/test/java/test/nz/ac/massey/cs/sdc/taxcalculator/IncomeTaxCalculatorBatchTest.java b/taxcalculator2/src/test/java/test/nz/ac/massey/cs/sdc/taxcalculator/IncomeTaxCalculatorBatchTest.java
new file mode 100755
index 0000000..90104f7
--- /dev/null
+++ b/taxcalculator2/src/test/java/test/nz/ac/massey/cs/sdc/taxcalculator/IncomeTaxCalculatorBatchTest.java
@@ -0,0 +1,66 @@
+package test.nz.ac.massey.cs.sdc.taxcalculator;
+
+import java.util.Arrays;
+import java.util.Collection;
+import static org.junit.Assert.*;
+import nz.ac.massey.cs.sdc.taxcalculator.IncomeTaxCalculator;
+import org.junit.*;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * Use parameterised tests to create tests quickly from data table.
+ * @author jens dietrich
+ */
+
+@RunWith(value = Parameterized.class)
+public class IncomeTaxCalculatorBatchTest {
+
+ private IncomeTaxCalculator calculator = null;
+
+ private double income = 0.0;
+ private double expectedIncomeTax = 0.0;
+
+ public IncomeTaxCalculatorBatchTest(double income, double expectedIncomeTax) {
+ super();
+ this.income = income;
+ this.expectedIncomeTax = expectedIncomeTax;
+ }
+
+ @Parameters
+ public static Collection<Object[]> data() {
+ Object[][] data = new Object[][] {
+ { 0,0},
+ { 10000,1050.0 } ,
+ { 20000,2520.0 } ,
+ { 30000,4270.0 } ,
+ { 40000,6020.0 } ,
+ { 50000,8020.0 } ,
+ { 60000,11020.0 } ,
+ { 70000,14020.0 } ,
+ { 80000,17320.0 } ,
+ { 90000,20620.0 } ,
+ { 100000,23920.0 }
+
+ };
+ return Arrays.asList(data);
+ }
+
+
+ @Before
+ public void setup() {
+ calculator = new IncomeTaxCalculator();
+ }
+ @After
+ public void tearDown() {
+ calculator = null;
+ }
+
+ @Test
+ public void test() {
+ double tax = calculator.calculateIncomeTax(this.income);
+ assertEquals(this.expectedIncomeTax,tax,0.01);
+ }
+
+}
diff --git a/taxcalculator2/src/test/java/test/nz/ac/massey/cs/sdc/taxcalculator/IncomeTaxCalculatorTest.java b/taxcalculator2/src/test/java/test/nz/ac/massey/cs/sdc/taxcalculator/IncomeTaxCalculatorTest.java
new file mode 100755
index 0000000..6435d58
--- /dev/null
+++ b/taxcalculator2/src/test/java/test/nz/ac/massey/cs/sdc/taxcalculator/IncomeTaxCalculatorTest.java
@@ -0,0 +1,91 @@
+package test.nz.ac.massey.cs.sdc.taxcalculator;
+
+import nz.ac.massey.cs.sdc.taxcalculator.IncomeTaxCalculator;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests cases for the income tax calculator based on the examples on the IRD web site:
+ * http://www.ird.govt.nz/how-to/taxrates-codes/itaxsalaryandwage-incometaxrates.html
+ * accessed on 9 August 12.
+ * @author jens dietrich
+ */
+public class IncomeTaxCalculatorTest {
+
+ private IncomeTaxCalculator calculator = null;
+
+ @Before
+ public void setup() {
+ calculator = new IncomeTaxCalculator();
+ }
+ @After
+ public void tearDown() {
+ calculator = null;
+ }
+
+ @Test
+ public void test1() {
+ double tax = calculator.calculateIncomeTax(65238);
+ assertEquals(12591.40,tax,0.01);
+ }
+
+ @Test
+ public void test2() {
+ double tax = calculator.calculateIncomeTax(45000);
+ assertEquals(6895.0,tax,0.01);
+ }
+
+ // boundary tests
+ @Test
+ public void testZero() {
+ double tax = calculator.calculateIncomeTax(0);
+ assertEquals(0,tax,0.01);
+ }
+
+ @Test
+ public void testSmallIncome() {
+ double tax = calculator.calculateIncomeTax(10);
+ assertEquals(1.05,tax,0.01);
+ }
+
+ @Test
+ public void testLargeIncome() {
+ double tax = calculator.calculateIncomeTax(Integer.MAX_VALUE);
+ // should be very close to the max tax rate
+ assertEquals(0.33*Integer.MAX_VALUE,tax,Integer.MAX_VALUE*0.001);
+ }
+
+ @Test
+ public void testNegativeIncome1() {
+ try {
+ @SuppressWarnings("unused")
+ double tax = calculator.calculateIncomeTax(-42);
+ assertTrue(false);
+ }
+ catch (IllegalArgumentException x) {
+ assertTrue(true);
+ }
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void testNegativeIncome2() {
+ calculator.calculateIncomeTax(-42);
+ }
+
+ @Test(timeout=100)
+ public void test1InclPerformance() {
+ double tax = calculator.calculateIncomeTax(65238);
+ assertEquals(12591.40,tax,0.01);
+ }
+
+ @Test(timeout=100)
+ public void test2InclPerformance() {
+ double tax = calculator.calculateIncomeTax(45000);
+ assertEquals(6895.0,tax,0.01);
+ }
+
+}
diff --git a/taxcalculator2/taxbrackets.json b/taxcalculator2/taxbrackets.json
new file mode 100644
index 0000000..89fac84
--- /dev/null
+++ b/taxcalculator2/taxbrackets.json
@@ -0,0 +1,22 @@
+[
+ {
+ "start": 0,
+ "end":14000,
+ "rate":10.5
+ },
+ {
+ "start": 14000,
+ "end":48000,
+ "rate":17.5
+ },
+ {
+ "start": 48000,
+ "end":70000,
+ "rate":30
+ },
+ {
+ "start": 70000,
+ "end":-1,
+ "rate":33
+ }
+]
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Sep 12, 10:54 AM (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42859
Default Alt Text
(21 KB)
Attached To
Mode
R21 OOP Examples
Attached
Detach File
Event Timeline
Log In to Comment