diff options
| author | mokha <mokha@cisco.com> | 2019-05-11 21:54:47 -0600 |
|---|---|---|
| committer | mokha <mokha@cisco.com> | 2019-05-11 21:54:47 -0600 |
| commit | 9a63fbc7fec8c6373e73aa4cfc917464fd3a5ca1 (patch) | |
| tree | b075eaf539e6155f1fe57b68694ccc365e0a8dc4 /src | |
| parent | 15c247d8c7c682ed8c3e5b864c51aab5227fed75 (diff) | |
calculate a tax of 33% of unknown status
Diffstat (limited to 'src')
| -rw-r--r-- | src/Q10/README.md | bin | 39045 -> 1480 bytes | |||
| -rw-r--r-- | src/Q10/TaxReturn.java | 8 | ||||
| -rw-r--r-- | src/Q10/TaxReturnTest.java | 5 |
3 files changed, 12 insertions, 1 deletions
diff --git a/src/Q10/README.md b/src/Q10/README.md Binary files differindex ab515c0..6590a30 100644 --- a/src/Q10/README.md +++ b/src/Q10/README.md diff --git a/src/Q10/TaxReturn.java b/src/Q10/TaxReturn.java index 7a9e32a..d30dc7d 100644 --- a/src/Q10/TaxReturn.java +++ b/src/Q10/TaxReturn.java @@ -58,7 +58,7 @@ public class TaxReturn { + RATE3 * (income - SINGLE_BRACKET2); if (income > 249999.0) tax += (income - 150000) * 0.25; - } else { + } else if (isMarried()) { if (income <= MARRIED_BRACKET1) tax = RATE1 * income; else if (income <= MARRIED_BRACKET2) tax = RATE1 * MARRIED_BRACKET1 + RATE2 * (income - MARRIED_BRACKET1); @@ -69,6 +69,8 @@ public class TaxReturn { + RATE3 * (income - MARRIED_BRACKET2); if (income > 349999.0) tax += (income - 200000) * 0.35; + } else { + tax = income * 0.33; } return tax; } @@ -90,6 +92,10 @@ public class TaxReturn { return this.status == SINGLE; } + private boolean isMarried() { + return this.status == MARRIED; + } + public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Please enter your income: "); diff --git a/src/Q10/TaxReturnTest.java b/src/Q10/TaxReturnTest.java index bb75097..c1af186 100644 --- a/src/Q10/TaxReturnTest.java +++ b/src/Q10/TaxReturnTest.java @@ -83,4 +83,9 @@ public class TaxReturnTest extends TestCase { TaxReturn subject = new TaxReturn(350000, TaxReturn.MARRIED); assertEquals(153751.0, subject.getTax()); } + + public void test_UNKNOWN_status_Should_tax_at_33_percent() { + TaxReturn subject = new TaxReturn(100000, 3); + assertEquals(33000.0, subject.getTax()); + } } |
