Question: You are required to complete the tasks described below. Test program The following program has been implemented for a newly proposed tax calculation formula for

You are required to complete the tasks described below.
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
1 public double computeTax(double[] incomeList, int[] parentList, int[] childList){
2 double taxAmount =0.0;
3 double incomeAmount =0.0;
// calculate the income amount
4 for (int i =0; i < incomeList.length; i++){
5 incomeAmount = incomeAmount + incomeList[i]; 6}
// calculate the basic tax
7 if (incomeAmount <=40000){
8 taxAmount = incomeAmount *0.02;
9} else if (incomeAmount >40000 && incomeAmount <=80000){
10 taxAmount =800+ incomeAmount *0.07;
11} else if (incomeAmount >80000 && incomeAmount <=120000){
12 taxAmount =800+2800+ incomeAmount *0.12;
13} else if (incomeAmount >120000){
14 taxAmount =800+2800+4800+ incomeAmount *0.17; 15}
// calculate the tax exemption from having children
16 int taxExemption =0;
17 int numOfChild = childList.length;
18 while (numOfChild >0){
19 if (childList[numOfChild -1]<18){
20 taxAmount = taxAmount -4000;
21 taxExemption = taxExemption +4000; 22}
23 numOfChild--; 24}
/ calculate the tax exemption from having parents
25 for (int j =0; j < parentList.length; j++){
26 if (parentList[j]>60){
27 taxAmount = taxAmount -2000;
28 taxExemption = taxExemption +2000; 29}
30}
// the maximum tax exemption is 8000 each person
31 if (taxExemption <=8000){
32 if (taxAmount >=0){
33 return taxAmount;
34} else {// i.e., taxAmount <0
35 return 0; 36}
37} else {// i.e., taxExemption >8000
38 taxAmount = taxAmount +(taxExemption -8000);
39
40 return taxAmount; 40}
41}
Your Tasks
(1) Draw the control flow graph for this program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!