Appendix G
Sequential and Selection Process Control Structure
In the following example, the second line of the table specifies that tax due on a salary of $2,000.00 is $225.00 plus 16% of excess salary over $1,500.00 (that is, 16% of $500.00). Therefore, the total tax is $225.00 + $80.00, or $305.00.
| |Salary Range in Dollars |Base Tax in Dollars |Percentage of Excess |
|1 |0.00-1,499.99 |0.00 |15 % |
|2 |1,500.00-2,999.99 |225.00 |16 % |
|3 |3,000.00-4,999.99 |465.00 |18 % |
|4 |5,000.00-7,999.99 |825.00 |20 % |
|5 |8,000.00-14,999.99 |1425.00 |25 % |
Main Module
Write “The purpose of this program is to calculate tax for a given salary range”
Input Data Module
1>Write "Enter Salary"
2>Read salary
3>
4>If (sal < 1500) then
5>Tax = sal * .15
6>
7>If (sal > 1499.99) AND (sal < 3000) then
8>Tax = 225 + (sal - 1500) * .16
9>
10>If (sal > 2999.99) AND (sal < 5000) then
11>Tax = 465 + (sal - 3000) * .18
12>
13>If (sal > 4999.99) AND (sal < 8000) then
14>Tax = 825 + (sal - 5000) * .20
15>
16>If (sal > 7999.99) AND (sal < 15000) then
17>Tax = 1425 + (sal - 8000) * .25
18>
19>Write "The tax is" Tax
Test Input Values
Enter salary 705
The tax is 108
Enter salary 1548
The tax is 2247.68
Enter salary 3050
The tax is 548
Enter salary 6076
The tax is 1215
Enter salary 10387
The tax is 2596.75
Design Walkthrough:
1.)Line 1 States “Enter Salary”
2.)The