Design test cases to achieve branch coverage on the function computeTax (list the branches covered...

90.2K

Verified Solution

Question

Accounting

Design test cases to achieve branch coverage on the function computeTax (list the branches covered by each test case). If it is not feasible, explain the reason. Use the minimum number of test cases to achieve the branch coverage.

HERE IS THE CODE NEEDED FOR PROBLEM:

// incomeList[]: the array recording the individual income items

// childList[]: the array recording the ages of children supported by this person

// parentList[]: the array recording the ages of parents supported by this person

  • public double computeTax(double[] incomeList, int[] parentList, int[] childList) {
  • double taxAmount = 0.0;
  • double incomeAmount = 0.0;
  • for (int i = 0; i < incomeList.length; i++) {
  • incomeAmount = incomeAmount + incomeList[i]; 6 }

if (incomeAmount <= 40000) {

  • taxAmount = incomeAmount * 0.02;
  • } else if (incomeAmount > 40000 && incomeAmount <= 80000) {
  • taxAmount = 800 + incomeAmount * 0.07;
  • } else if (incomeAmount > 80000 && incomeAmount <= 120000) {
  • taxAmount = 800 + 2800 + incomeAmount * 0.12;
  • } else if (incomeAmount > 120000) {
  • taxAmount = 800 + 2800 + 4800 + incomeAmount * 0.17; 15 }
  • int taxExemption = 0;
  • int numOfChild = childList.length;
  • while (numOfChild > 0) {
  • if (childList[numOfChild - 1] < 18) {
  • taxAmount = taxAmount - 4000;
  • taxExemption = taxExemption + 4000; 22 }

23 numOfChild--; 24 }

  • for (int j = 0; j < parentList.length; j++) {
  • if (parentList[j] > 60) {
  • taxAmount = taxAmount - 2000;
  • taxExemption = taxExemption + 2000; 29 }

// the maximum tax exemption is 8000 each person

  • if (taxExemption <= 8000) {
  • if (taxAmount >= 0) {
  • return taxAmount;
  • } else { // i.e., taxAmount <0
  • return 0; 36 }
  • } else { // i.e., taxExemption > 8000
  • taxAmount = taxAmount + (taxExemption - 8000);
  • return taxAmount; 40 }

Answer & Explanation Solved by verified expert
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students