217,573 views
2 votes
2 votes
When the function below is called with 1 dependent and $400 as grossPay, what value is returned?

double computeWithholding (int dependents, double grossPay)

{
double withheldAmount;
if (dependents > 2)
withheldAmount = 0.15;
else if (dependents == 2)
withheldAmount = 0.18;
else if (dependnets == 1)
withheldAmount = 0.2;
else // no dependents
withheldAmount = 0.28;
withheldAmount = grossPay * withheldAmount;
return (withheldAmount);
}

a. 60.0
b. 80.0
c. 720.0
d. None of these

User Maria Khalusova
by
2.9k points

1 Answer

7 votes
7 votes

Answer:

b. 80.0

Step-by-step explanation:

Given


dependent = 1


grossPay = \$400

Required

Determine the returned value

The following condition is true for: dependent = 1

else if (dependnets == 1)

withheldAmount = 0.2;

The returned value is calculated as:


withheldAmount = grossPay * withheldAmount;

This gives:


withheldAmount = 400 * 0.2


withheldAmount = 80.0

Hence, the returned value is 80.0

User Samy Sammour
by
4.0k points