CheckPoint: Sequential and Selection Processing Control Structure
Analysis of problem:
Process: 1. Display welcome message and program title on main page. 2. User inputs the salary. 3. Based on salary amount calculate the taxes. 4. Display results.
Input (real) Salary
Output Total Salary with taxes (Real = Taxes)
Input Data and Output Process Input | Processes | Output | Input Salary | Input user data | Salary | Taxes | Calculate Taxes | Taxes | Salary plus taxes | Output total | Display Salary & taxes. |
Pseudocode layout:
Main Program Module: Declare Salary (Real) Declare Taxes (Real) Display on main screen “Salary Tax Calculator” Call Salary Module Call Calculate Taxes Module Call display taxes module
End Program
Get Salary
Display “Enter salary information.” Get Salary Information
Calculate Taxes
Declare (Real) = Base Tax Amount
Declare (Real) = Excess Income
Declare (Real) = Rate
Sequential and Selection Process Control Structure
| Salary Range in Dollars | Base Tax in Dollars | Percentage of Excess | 1. 1 | 0.00-1,499.99 | 0.00 | 15 % | 2. 2 | 1,500.00-2,999.99 | 225.00 | 16 % | 3. 3 | 3,000.00-4,999.99 | 465.00 | 18 % | 4. 4 | 5,000.00-7,999.99 | 825.00 | 20 % | 5. 5 | 8,000.00-14,999.99 | 1425.00 | 25 % |
Set taxes = Base Tax + (Excess * Rate)
End calculate Taxes
Display Taxes
Display Salary = $, (Salary), Taxes = $, (Taxes)
End Display Taxes
Test Values Salary Input | Expected Output | Comments | Salary 0.0 | Error Message Salary = $0.0 Taxes = $0.0 | input out of valid range | Salary 0.01 | Salary = $0.01 Taxes = $0.0015 | lower limit first tax interval | Salary 1000.00 | Salary = $1000.00 Taxes = $150 | Middle of first tax interval | Salary 1499.99 | Salary = $1499.00 Taxes = $225.00 |