Commit 9a63fbc

mokha <mokha@cisco.com>
2019-05-12 03:54:47
calculate a tax of 33% of unknown status
1 parent 15c247d
src/Q10/README.md
Binary file
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: ");
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());
+  }
 }