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

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 15:00
Based on the current economic situation do you expect the employment demand for graduating engineers to increase or decrease? explain the basis for your answer. with a significant economic recovery, what do you think will happen to future enrollments in graduating engineering programs?
Answers: 1
question
Computers and Technology, 23.06.2019 20:00
Me ajude por favor , coloquei uma senha e não consigo tira-la no chorme
Answers: 2
question
Computers and Technology, 24.06.2019 02:30
Which option completes the explanation for conflict of interest in an organization
Answers: 1
question
Computers and Technology, 24.06.2019 13:10
Write a program that has a conversation with the user. the program must ask for both strings and numbers as input. the program must ask for at least 4 different inputs from the user. the program must reuse at least 3 inputs in what it displays on the screen. the program must perform some form of arithmetic operation on the numbers the user inputs. turn in your .py file as well as a screenshot of your program's output. include comments in your code to explain how it works an example program run might look like (have fun with this and be creative): ‘what is your name? ’ “josh” ‘, josh. what is your favorite color? ’ “green” ‘mine too. do you also like ice cream? ’ “no” ‘josh, how old are you? ’ “40” ‘ and how many siblings do you have? ’’ “3” ‘that means you are one of 4 kid(s). is green the favorite color of anyone else in your house? ’
Answers: 3
You know the right answer?
// incomeList[]: the array recording the individual income items // childList[]: the array recordin...
Questions
question
Chemistry, 09.02.2021 09:30
question
Mathematics, 09.02.2021 09:30
question
Social Studies, 09.02.2021 09:30
question
Mathematics, 09.02.2021 09:30
Questions on the website: 13722361