Sie sind auf Seite 1von 5

Axia College Material

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 $2000.00 is $225.00 plus 16% of excess salary over $1500.00 (that is, 16% of $500.00). Therefore, the total tax is $225.00 + $80.00, or $305.00.

Salary Range in Dollars


1 2 3 4 5

Base Tax in Dollars 0.00 225.00 465.00 825.00 1425.00

Percentage of Excess 15 % 16 % 18 % 20 % 25 %

0.00-1,499.99 1,500.00-2,999.99 3,000.00-4,999.99 5,000.00-7,999.99 8,000.00-14,999.99

Main Module Declare Associate_Name as string Declare Salary_Amount as real Declare Base as real Declare Excess as real Declare Salary as real Declare Start_Over as string REM these are the calls for the modules that can be ran. Not all modules will run REM because associates will only fall into 1 tax bracket Call Input Data Module Call Range Module

IT 210

Call Salary1 Module Call Salary2 Module Call Salary3 Module Call Salary4 Module Call Salary5 Module Call Output Module End Main Module Input Data Module Write, Please Enter Associates Full Name Input Associate_Name Write, Associates Salary Amount? Input Salary_Amount Call Range Module End Input Data Module Range Module

REM these statements (if, then, else) will determine what module to call upon. If Salary_Amount < 1,499.99 Then Call Salary1 Module Else If Salary_Amount > 1,500.00 AND Salary_Amount < 2,999.99 Then Call Salary2 Module Else If Salary_Amount > 3,000.00 AND Salary_Amount < 4,999.99 Then Call Salary3 Module

IT 210

Else If Salary_Amount > 5,000.00 AND Salary_Amount < 7,999.99 Then Call Salary4 Module Else If Salary_Amount > 8,000.00 AND Salary_Amount < 14,999.99 Then Call Salary5 Module Else Write, The salary you typed in is not computable. Write, Please enter a salary between 0.00 and 14,999.99. Call Input Module End Range Module Salary 1 Module Declare Excess as real Declare Salary as Real Set Excess = Salary_Amount * .015 Set Salary = Salary_Amount - Excess Call Output Module End Salary 1 Module Salary 2 Module Declare Base as real Declare Excess as real Declare Salary as real Set Base = Salary_Amount - 225 Set Excess = Base * .16 Set Salary = Base - Excess Call Output Module End Salary 2 Module Salary 3 Module

IT 210

Declare Base as real Declare Excess as real Declare Salary as real Set Base = Salary_Amount - 465 Set Excess = Base * .18 Set Salary = Base - Excess Call Output Module End Salary 3 Module Salary 4 Module Declare Base as real Declare Excess as real Declare Salary as real Set Base = Salary_Amount - 825 Set Excess = Base * .20 Set Salary = Base - Excess Call Output Module End Salary 4 Module Salary 5 Module Declare Base as real Declare Excess as real Declare Salary as real Set Base = Salary_Amount - 1425 Set Excess = Base * .25 Set Salary = Base - Excess Call Output Module End Salary 5 Module

Output Module Declare Start_Over as string Declare Associate_Name as string Declare Salary as real

IT 210

Write, The gross salary for, Associate_Name Salary Write, Wanna start this from the beginning? Enter Y or N Input Start_Over If Start_Over = Y or y Then Call Input Module Else If Start_Over = N or n Then End Else Write, Cannot Computer Your Answer, Shutting Down. End End Output Module Input Test Values: Associate_Name: Cody Johnson Salary: 10,150.00 The gross salary for Cody Johnson 6543.75 Associate Name: Matthew Johnson Salary: 5000.00 The gross salary for Matthew Johnson 3340

IT 210

Das könnte Ihnen auch gefallen