.Do the planning and write an algorithm to

solve the following problem. Prepare test
data for the example to test all possibilities
and draw a trace table.
Sam works at a coffee company where all
the employees receive a bonus of R700,
except the employees in the coffee
department 3, who receive a bonus of R850.
Enter his gross salary and his personal
department number. Calculate the total
income of Sam. Subtract 25% of the gross
income for tax. Determine and display
Sam’s net income on the screen.

prompt for name, dept, salary

read name, dept, salary
bonus = (dept = 3) : 850 : 700
gross = salary+bonus
net = gross * 0.75
display name, net

To solve this problem, we can follow these steps:

1. Read the gross salary of Sam and his department number.
2. Check if the department number is 3 or not.
- If the department number is 3, the bonus amount is R850.
- If the department number is not 3, the bonus amount is R700.
3. Calculate the total income of Sam by adding the gross salary with the bonus amount.
4. Calculate the tax amount by subtracting 25% of the gross salary.
5. Calculate the net income by subtracting the tax amount from the total income.
6. Display the net income of Sam on the screen.

Example Algorithm:

```
1. Read gross_salary, department_number
2. bonus_amount = 0
3. if department_number is equal to 3, then
bonus_amount = 850
else
bonus_amount = 700
4. total_income = gross_salary + bonus_amount
5. tax_amount = 0.25 * gross_salary
6. net_income = total_income - tax_amount
7. Display net_income
```

To test all possibilities, you can prepare test data with different values for gross_salary and department_number. For example:

Test Data:
1. gross_salary = 5000, department_number = 1
2. gross_salary = 7000, department_number = 3
3. gross_salary = 10000, department_number = 2

Based on these test data, you can create a trace table to track the values of variables and the execution flow of the algorithm. For each test data, record the values of gross_salary, department_number, bonus_amount, total_income, tax_amount, and net_income.

Example Trace Table:

| Test Data | gross_salary | department_number | bonus_amount | total_income | tax_amount | net_income |
|-----------|--------------|-------------------|--------------|--------------|-------------|------------|
| 1 | 5000 | 1 | 700 | 5700 | 1250 | 4450 |
| 2 | 7000 | 3 | 850 | 7850 | 1750 | 6100 |
| 3 | 10000 | 2 | 700 | 10700 | 2500 | 8200 |

By following this algorithm and using different test data, you can calculate and display the net income of Sam based on his gross salary and department number.