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 % |
You are an accountant setting up a payroll system for a small firm. Each line of the table in Appendix G indicates an employee’s salary range and corresponding base tax amount and tax percentage. Given a salary amount, the tax is calculated by adding the base tax for that salary range and the product of percentage of excess and the amount of salary over the minimum salary for that range.
1. Input data
2. Determine tax bracket
3. Subtract actual salary from base salary
4. multiply difference by percent based on tax bracket 5. Add product to base tax
6. Display total tax
|Input |Process |Output | | |Display Salary |Amount_of_Salary(number) | |Salary | | | | |Select correct tax bracket |Tax-bracket(number) | |Tax Bracket | | | |Tax determining formulas |Choose correct formula and |Amount_of_tax(number) | | |calculate | | |Total Tax |Display Tax |Tax(number) |
Declare Salary_Min as float
Declare Salary_max as float
Declare Tax_Base as float
Declare Excess_percent as float
Declare tax as float
Write" This program determines the tax on the salaries entered" Call Input Data module
Call Perform Operations module
Call Output Results module
End Main Module
Input Data Module:
Write" What is the Salary?"
Perform Calculations Mode:
If Salary is 0.00-1,499.99, then tax= (salary-0)*15+0 If Salary is 1,500.00-2,999.99 then tax = (salary-1500)*16+225 If Salary is 3,000.00-4,999.99 then tax = (salary-3000)*18+465 If Salary is 5,000.00-7,999.99 then tax = (salary-5000)*20+825 If Salary is 8,000.00-14,999.99 then tax = (salary-8000)*25+1425 End Perform Calculations Mode
Output Results Module
Write "That tax for the Salary given is +tax...