subject

// 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;
// calculate the income amount
for (int i = 0; i < incomeList. length; i++) {
incomeAmount = incomeAmount + incomeList[i]; 6 }
// calculate the basic tax
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 }
// calculate the tax exemption from having children
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 }
// calculate the tax exemption from having parents
for (int j = 0; j < parentList. length; j++) {
if (parentList[j] > 60) {
taxAmount = taxAmount - 2000;
taxExemption = taxExemption + 2000; 29 }
30 }
// 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;
}
}
Design test cases to achieve loop coverage (see below) on the function "computeTax" (list the loops covered by each test case). If it is not feasible, explain the reason. Try your best to use the minimum number of test cases to achieve the loop coverage. Consider a loop covered if at least in one test the loop body was executed 0 times, in a second test the body was executed exactly once, and in another test the body was executed more than once.

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 15:20, brookemcelhaney
The north and south regions had very diferent economies in the 1800s.
Answers: 1
image
Computers and Technology, 23.06.2019 02:00, kayladgranger
Which demographic challenge is europe currently experiencing? a. an aging and decreasing population b. a baby boomc. an unequal distribution between males and females d. a large group of teenagers moving through the school system(i chose a but i'm unsure)
Answers: 1
image
Computers and Technology, 23.06.2019 09:00, mimithurmond03
Which is the highest level of the hierarchy of needs model? a. humanity b. intrapersonal c. team d. interpersonal
Answers: 1
image
Computers and Technology, 23.06.2019 16:00, lokaranjan5736
Write a grading program for a class with the following grading policies: a. there are two quizzes, each graded on the basis of 10 points. b. there is one midterm exam and one final exam, each graded on the basis of 100 points. c. the final exam counts for 50% of the grade, the midterm counts for 25%, and the two quizzes together count for a total of 25%. (do not forget to normalize the quiz scores. they should be converted to a percentage before they are averaged in.) any grade of 90 or more is an a, any grade of 80 or more (but less than 90) is a b, any grade of 70 or more (but less than 80) is a c, any grade of 60 or more (but less than 70) is a d, and any grade below 60 is an f. the program will read in the student’s scores and output the student’s record, which consists of two quiz and two exam scores as well as the student’s average numeric score for the entire course and final letter grade. define and use a structure for the student reco
Answers: 2
You know the right answer?
// incomeList[]: the array recording the individual income items // childList[]: the array recordin...

Questions in other subjects:

Konu
Mathematics, 12.01.2021 21:00
Konu
Mathematics, 12.01.2021 21:00
Konu
Mathematics, 12.01.2021 21:00
Konu
Mathematics, 12.01.2021 21:00
Konu
Chemistry, 12.01.2021 21:00