Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Test program The following program has been implemented for a newly proposed tax calculation formula for residents of a fictitious country. / / incomeList [
Test program
The following program has been implemented for a newly proposed tax calculation formula for residents of a
fictitious country.
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 computeTaxdouble incomeList, int parentList, int childList
double taxAmount ;
double incomeAmount ;
calculate the income amount
for int i ; i incomeList.length; i
incomeAmount incomeAmount incomeListi;
calculate the basic tax
if incomeAmount
taxAmount incomeAmount ;
else if incomeAmount && incomeAmount
taxAmount incomeAmount ;
else if incomeAmount && incomeAmount
taxAmount incomeAmount ;
else if incomeAmount
taxAmount incomeAmount ;
calculate the tax exemption from having children
int taxExemption ;
int numOfChild childList.length;
while numOfChild
if childListnumOfChild
taxAmount taxAmount ;
taxExemption taxExemption ;
numOfChild;
calculate the tax exemption from having parents
for int j ; j parentList.length; j
if parentListj
taxAmount taxAmount ;
taxExemption taxExemption ;
the maximum tax exemption is each person
if taxExemption
if taxAmount
return taxAmount;
else ie taxAmount
return ;
else ie taxExemption
taxAmount taxAmount taxExemption ;
return taxAmount;
Your Tasks
Draw the control flow graph for this program.
Design test cases to achieve the statement coverage on the function computeTaxlist the statements
covered by each test case using the line number of each statement If statement coverage is not feasible,
explain the reason. Use the minimum number of test cases to achieve the statement coverage.
Design test cases to achieve branch coverage on the function computeTaxlist the branches covered
by each test case If branch coverage is not feasible, explain the reason. Use the minimum number of test
cases to achieve branch coverage.
Design test cases to achieve loop coverage on the function computeTaxlist 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 times, in a second
test the body was executed exactly once, and in another test the body was executed more than once.
Special Instructions
Test cases should be presented in a table with each row showing the following:
Test ID # input data, statementsbranchesloops covered by the test case, expected output and coverage You
may add additional columns to display key variables such as tax exemption.
Code coverage should be shown by listing the statements using line numbers for each test case.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started