Consider the following tax calculation program that implements the following tax calculation criteria.
Tax Calculation Criteria:
a) Label the nodes in the code segment above and draw the control flow graph.
b) List independent paths.
c) Develop test cases in a table.
d) Write JUnit test cases to implement your test cases in part (c) above.
Label the solutions to a, b, and c above. Write a JUnit Java program for part d and name it TaxCalculationTest.java.
Income range:
- Less than 0 or greater than one million
- 25001 to 50000
- 50001 to 100000
- 100001 to 1000000
Tax Rate:
- Invalid input for this program
- 0.33
public class TaxCalculation {
public static double calculateTax(double income) {
double tax = 0, taxRate = 0;
if (income < 0 || income > 1000000) {
return taxRate;
} else if (income >= 0 && income <= 25000) {
taxRate = 0;
} else if (income <= 50000) {
taxRate = 0.20;
} else if (income <= 100000) {
taxRate = 0.25;
} else if (income <= 1000000) {
taxRate = 0.33;
}
tax = income * taxRate;
return tax;
}
}