An accountant requests a program that calculates the amount of tax a person is required to pay. If the income exceeds $30,000.00, the tax rate is 38 percent. If the income is less than or equal to $30,0000.00, the tax rate is 28 percent. The question is this: is income greater than or equal to $30,000.00? Or, the question may be represented by the formula in Figure 1.
Figure : Formula for tax rate example
Keys

Display

Description

Press LS, then PRGM


Enters Program mode

Press RS, then CLPRGM

00

Clears previous programs

Press RS, LBL, then A

01 61 41 A

Names program

Press INPUT

02 31

Enters display value into xposition for conditional test

Press 3

03 3

Enters first digit of 30,000

Press 0

04 0


Press 0

05 0


Press 0

06 0


Press 0

07 0

Enters last digit of 30,000

Press RS, then x<y?

08 61 42

Conditional test: is x less than or equal to 30,000? Does next line if true, otherwise skips one line

Press LS, GTO, then 0

09 51 41 0

Goes to label 0 if income is less than or equal to 30,000

Press LS, then SWAP

10 51 31

Exchanges 30,000 and income

Press x

11 55

Multiplies xvalue

Press 3

12 3

Each digit uses one program line

Press 8

13 8

Enters tax rate

Press LS, then %

14 51 14


Press =

15 74

38 percent of xvalue

Press R/S

16 26

Halts program

Press RS, LBL, then 0

17 61 41 0

Starts routine for income less than or equal to 30,000

Press LS, then SWAP

18 51 31

Exchanges 30,000 and xvalue

Press x

19 55

Multiplies xvalue

Press 2

20 2

Each digit uses one program line

Press 8

21 8

Enters tax rate

Press LS, then %

22 51 14


Press =

23 74

28 percent of xvalue

Press R/S

24 26

Halts the program

Hold LS, and SHOW

d6b6

Checksum (see Checksum below)

Press LS, then PRGM


Exits Program mode

Test the program by comparing samples done manually. For example, pressing 15000, x, 28, LS, %, then =, should result in 4,200.0000. Test a few more incomes manually, then run the program and compare them. To run the program, enter the income value in the display and press XEQ, then A
The : that appears in the display after the program is complete is caused by the INPUT that separates income from 30,000 for the conditional test in line 08. The program can be rewritten so that x is used to separate income from 30,000 for the conditional test. Also, to save program lines, the common keystrokes can be grouped together. The following program uses conditional branching and unconditional branching for the common keystrokes.
Keys

Display

Description

Press LS, then PRGM


Enters Program mode

Press RS, then CLPRGM

00

Clears any existing programs

Press RS, LBL, then A

01 61 41 A

Names program A

Press x

02 55

Puts display value into xposition for conditional. It will be used later to multiply by the tax rate

Press 3

03 3

One digit per line

Press 0

04 0


Press 0

05 0


Press 0

06 0


Press 0

07 0

yvalue is 30,000

Press RS, then x<y?

08 61 42

If yes, goes to next line; if no, skips one line

Press LS, GTO, then 1

09 51 41 1

Goes to label 1 if income is less than or equal to 30,000

Press 3

10 3

Replaces 30,000 by the tax rate

Press 8

11 8


Press LS, GTO, then 2

12 51 41 2

Goes to label 2 for common steps

Press RS, LBL, then 1

13 61 41 1

Starts routine 1 for x is less than or equal to 30,000

Press 2

14 2

One digit per line

Press 8

15 8


Press RS, LBL, then 2

16 61 41 2

Starts routine 2 with common lines

Press LS, then %

17 51 14

Calculates 38 percent or 28 percent ...

Press =

18 74

... of income

Press R/S

19 26

End of program

Hold LS, and SHOW

CbCA

Checksum (see Checksum below)

Press LS, then PRGM


Exits Program mode

Test this program the same way as the previous program for the tax rate example. Press C to remove the : from the previous example.